com.amazonaws.waiters.WaiterParameters Java Examples
The following examples show how to use
com.amazonaws.waiters.WaiterParameters.
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: CFInvalidateStep.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Override protected Void run() throws Exception { TaskListener listener = this.getContext().get(TaskListener.class); AmazonCloudFront client = AWSClientFactory.create(AmazonCloudFrontClientBuilder.standard(), this.getContext()); String distribution = this.step.getDistribution(); String[] paths = this.step.getPaths(); boolean waitForCompletion = this.step.getWaitForCompletion(); listener.getLogger().format("Invalidating paths %s in distribution %s%n", Arrays.toString(paths), distribution); Paths invalidationPaths = new Paths().withItems(paths).withQuantity(paths.length); InvalidationBatch batch = new InvalidationBatch(invalidationPaths, Long.toString(System.currentTimeMillis())); String invalidationId = client.createInvalidation(new CreateInvalidationRequest(distribution, batch)).getInvalidation().getId(); listener.getLogger().format("Invalidation %s enqueued%n", invalidationId); if (waitForCompletion) { listener.getLogger().format("Waiting for invalidation %s to be completed...%n", invalidationId); client.waiters().invalidationCompleted().run(new WaiterParameters<GetInvalidationRequest>(new GetInvalidationRequest(distribution, invalidationId))); listener.getLogger().format("Invalidation %s completed%n", invalidationId); } return null; }
Example #2
Source File: EventPrinter.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
void waitAndPrintChangeSetEvents(String stack, String changeSet, Waiter<DescribeChangeSetRequest> waiter, PollConfiguration pollConfiguration) throws ExecutionException { final BasicFuture<AmazonWebServiceRequest> waitResult = new BasicFuture<>(null); waiter.runAsync(new WaiterParameters<>(new DescribeChangeSetRequest().withStackName(stack).withChangeSetName(changeSet)).withPollingStrategy(this.pollingStrategy(pollConfiguration)), new WaiterHandler() { @Override public void onWaitSuccess(AmazonWebServiceRequest request) { waitResult.completed(request); } @Override public void onWaitFailure(Exception e) { waitResult.failed(e); } }); this.waitAndPrintEvents(stack, pollConfiguration, waitResult); }
Example #3
Source File: EventPrinter.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
void waitAndPrintStackEvents(String stack, Waiter<DescribeStacksRequest> waiter, PollConfiguration pollConfiguration) throws ExecutionException { final BasicFuture<AmazonWebServiceRequest> waitResult = new BasicFuture<>(null); waiter.runAsync(new WaiterParameters<>(new DescribeStacksRequest().withStackName(stack)).withPollingStrategy(this.pollingStrategy(pollConfiguration)), new WaiterHandler() { @Override public void onWaitSuccess(AmazonWebServiceRequest request) { waitResult.completed(request); } @Override public void onWaitFailure(Exception e) { waitResult.failed(e); } }); this.waitAndPrintEvents(stack, pollConfiguration, waitResult); }
Example #4
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 #5
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 #6
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 #7
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 #8
Source File: S3Utils.java From wildfly-camel with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public static void createBucket(AmazonS3Client client, String bucketName) throws Exception { client.createBucket(bucketName); HeadBucketRequest request = new HeadBucketRequest(bucketName); Waiter<HeadBucketRequest> waiter = client.waiters().bucketExists(); Future<Void> future = waiter.runAsync(new WaiterParameters<HeadBucketRequest>(request), new NoOpWaiterHandler()); future.get(1, TimeUnit.MINUTES); }
Example #9
Source File: KinesisUtils.java From wildfly-camel with Apache License 2.0 | 5 votes |
public static void createStream(AmazonKinesisClient client, String streamName) throws Exception { client.createStream(streamName, 1); Waiter<DescribeStreamRequest> waiter = client.waiters().streamExists(); DescribeStreamRequest request = new DescribeStreamRequest().withStreamName(streamName); Assert.assertNotNull("Cannot obtain stream description", request); Future<Void> future = waiter.runAsync(new WaiterParameters<DescribeStreamRequest>(request), new NoOpWaiterHandler()); future.get(1, TimeUnit.MINUTES); }
Example #10
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); } }