Java Code Examples for com.amazonaws.waiters.Waiter#runAsync()

The following examples show how to use com.amazonaws.waiters.Waiter#runAsync() . 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: EventPrinter.java    From pipeline-aws-plugin with Apache License 2.0 6 votes vote down vote up
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 2
Source File: EventPrinter.java    From pipeline-aws-plugin with Apache License 2.0 6 votes vote down vote up
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 3
Source File: S3Utils.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@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 4
Source File: KinesisUtils.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
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);
    }