Java Code Examples for com.amazonaws.waiters.Waiter#run()
The following examples show how to use
com.amazonaws.waiters.Waiter#run() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWSProvider.java From testgrid with Apache License 2.0 | 5 votes |
/** * This method releases the provisioned AWS infrastructure. * * @param script the script config * @param inputs * @return true or false to indicate the result of destroy operation. * @throws TestGridInfrastructureException when AWS error occurs in deletion process. * @throws InterruptedException when there is an interruption while waiting for the result. */ private boolean doRelease(Script script, Properties inputs, TestPlan testPlan) throws TestGridInfrastructureException, InterruptedException, TestGridDAOException { Path configFilePath; String stackName = script.getName(); String region = inputs.getProperty(AWS_REGION_PARAMETER); configFilePath = TestGridUtil.getConfigFilePath(); AmazonCloudFormation stackdestroy = AmazonCloudFormationClientBuilder.standard() .withCredentials(new PropertiesFileCredentialsProvider(configFilePath.toString())) .withRegion(region) .build(); DeleteStackRequest deleteStackRequest = new DeleteStackRequest(); deleteStackRequest.setStackName(stackName); stackdestroy.deleteStack(deleteStackRequest); logger.info(StringUtil.concatStrings("Stack : ", stackName, " is handed over for deletion!")); //Notify AWSResourceManager about stack destruction to release acquired resources AWSResourceManager awsResourceManager = new AWSResourceManager(); awsResourceManager.notifyStackDeletion(testPlan, script, region); boolean waitForStackDeletion = Boolean .parseBoolean(getProperty(ConfigurationProperties.WAIT_FOR_STACK_DELETION)); if (waitForStackDeletion) { logger.info(StringUtil.concatStrings("Waiting for stack : ", stackName, " to delete..")); Waiter<DescribeStacksRequest> describeStacksRequestWaiter = new AmazonCloudFormationWaiters(stackdestroy).stackDeleteComplete(); try { describeStacksRequestWaiter.run(new WaiterParameters<>(new DescribeStacksRequest() .withStackName(stackName))); } catch (WaiterUnrecoverableException e) { throw new TestGridInfrastructureException("Error occurred while waiting for Stack :" + stackName + " deletion !"); } } return true; }
Example 2
Source File: ECSService.java From amazon-ecs-plugin with MIT License | 5 votes |
public void waitForTasksRunning(String tasksArn, String clusterArn, long timeoutInMillis, int DelayBetweenPollsInSeconds) { final AmazonECS client = clientSupplier.get(); Waiter<DescribeTasksRequest> describeTaskWaiter = new AmazonECSWaiters(client).tasksRunning(); describeTaskWaiter.run(new WaiterParameters<DescribeTasksRequest>( new DescribeTasksRequest() .withTasks(tasksArn) .withCluster(clusterArn) .withSdkClientExecutionTimeout((int)timeoutInMillis)) .withPollingStrategy(new PollingStrategy(new MaxTimeRetryStrategy(timeoutInMillis), new FixedDelayStrategy(DelayBetweenPollsInSeconds)))); }
Example 3
Source File: AwsTerminateService.java From cloudbreak with Apache License 2.0 | 5 votes |
private void waitAndDeleteCloudformationStack(AuthenticatedContext ac, CloudStack stack, List<CloudResource> resources, AmazonCloudFormationClient amazonCloudFormationClient) { CloudResource stackResource = cfStackUtil.getCloudFormationStackResource(resources); if (stackResource == null) { LOGGER.debug("No cloudformation stack in resources"); return; } String cFStackName = stackResource.getName(); AmazonCloudFormationRetryClient cfRetryClient = awsClient.createCloudFormationRetryClient(amazonCloudFormationClient); LOGGER.debug("Search and wait stack with name: {}", cFStackName); DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest().withStackName(cFStackName); try { retryService.testWith2SecDelayMax15Times(() -> isStackExist(cfRetryClient, cFStackName, describeStacksRequest)); } catch (ActionFailedException ignored) { LOGGER.debug("Stack not found with name: {}", cFStackName); return; } resumeAutoScalingPolicies(ac, stack); LOGGER.debug("Delete cloudformation stack from resources"); DeleteStackRequest deleteStackRequest = new DeleteStackRequest().withStackName(cFStackName); cfRetryClient.deleteStack(deleteStackRequest); Waiter<DescribeStacksRequest> stackDeleteCompleteWaiter = amazonCloudFormationClient.waiters().stackDeleteComplete(); try { WaiterParameters<DescribeStacksRequest> describeStacksRequestWaiterParameters = new WaiterParameters<>(describeStacksRequest) .withPollingStrategy(getBackoffCancellablePollingStrategy(null)); stackDeleteCompleteWaiter.run(describeStacksRequestWaiterParameters); } catch (Exception e) { LOGGER.debug("Cloudformation stack delete failed ", e); throw new CloudConnectorException(e.getMessage(), e); } LOGGER.debug("Cloudformation stack from resources has been deleted"); }
Example 4
Source File: WaiterRunner.java From cloudbreak with Apache License 2.0 | 5 votes |
public static <I extends AmazonWebServiceRequest> void run(Waiter<I> waiter, I input, CancellationCheck cancellationCheck) { try { waiter.run(new WaiterParameters<I>() .withRequest(input) .withPollingStrategy(getBackoffCancellablePollingStrategy(cancellationCheck)) ); } catch (Exception e) { throw new CloudConnectorException(e.getMessage(), e); } }
Example 5
Source File: CodeDeployUtils.java From herd-mdl with Apache License 2.0 | 4 votes |
/** * Waits for a given deployment to succeed (or fail). * * @param deploymentId: String. The specified deployment's id. */ public static void waitForMostRecentDeployment(String deploymentId) { LOGGER.debug("Waiting on deployment with id: \'{}\'", deploymentId); AmazonCodeDeploy codeDeployClient = AmazonCodeDeployClientBuilder.standard() .withRegion(Regions.US_EAST_1).build(); GetDeploymentRequest getDeploymentRequest = new GetDeploymentRequest(); getDeploymentRequest.setDeploymentId(deploymentId); Waiter<GetDeploymentRequest> waiter = codeDeployClient.waiters().deploymentSuccessful(); try { waiter.run(new WaiterParameters<>(getDeploymentRequest)); LOGGER.info("Deployment was successful."); } catch (WaiterUnrecoverableException | WaiterTimedOutException e) { LOGGER.error("Deployment with id: {} was unsuccessful.", deploymentId); } }