Example usage for com.amazonaws.waiters WaiterParameters WaiterParameters

List of usage examples for com.amazonaws.waiters WaiterParameters WaiterParameters

Introduction

In this page you can find the example usage for com.amazonaws.waiters WaiterParameters WaiterParameters.

Prototype

public WaiterParameters(Input request) 

Source Link

Usage

From source file:de.taimos.pipeline.aws.cloudformation.EventPrinter.java

License:Apache License

public void waitAndPrintChangeSetEvents(String stack, String changeSet, Waiter<DescribeChangeSetRequest> waiter,
        long pollIntervalMillis) throws ExecutionException {

    final BasicFuture<AmazonWebServiceRequest> waitResult = new BasicFuture<>(null);

    waiter.runAsync(//  w  w  w  .  jav  a 2 s  .  co m
            new WaiterParameters<>(
                    new DescribeChangeSetRequest().withStackName(stack).withChangeSetName(changeSet)),
            new WaiterHandler() {
                @Override
                public void onWaitSuccess(AmazonWebServiceRequest request) {
                    waitResult.completed(request);
                }

                @Override
                public void onWaitFailure(Exception e) {
                    waitResult.failed(e);
                }
            });

    this.waitAndPrintEvents(stack, pollIntervalMillis, waitResult);
}

From source file:de.taimos.pipeline.aws.cloudformation.EventPrinter.java

License:Apache License

public void waitAndPrintStackEvents(String stack, Waiter<DescribeStacksRequest> waiter, long pollIntervalMillis)
        throws ExecutionException {

    final BasicFuture<AmazonWebServiceRequest> waitResult = new BasicFuture<>(null);

    waiter.runAsync(new WaiterParameters<>(new DescribeStacksRequest().withStackName(stack)),
            new WaiterHandler() {
                @Override// w  w  w. j  av a 2 s  .c  o m
                public void onWaitSuccess(AmazonWebServiceRequest request) {
                    waitResult.completed(request);
                }

                @Override
                public void onWaitFailure(Exception e) {
                    waitResult.failed(e);
                }
            });
    this.waitAndPrintEvents(stack, pollIntervalMillis, waitResult);
}

From source file:org.springframework.integration.aws.metadata.DynamoDbMetaDataStore.java

License:Apache License

@Override
public void afterPropertiesSet() throws Exception {
    try {/*www  .ja v a2  s  . c  o  m*/
        this.table.describe();
        createTableLatch.countDown();
        return;
    } catch (ResourceNotFoundException e) {
        if (logger.isInfoEnabled()) {
            logger.info("No table '" + this.table.getTableName() + "'. Creating one...");
        }
    }

    CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(this.table.getTableName())
            .withKeySchema(new KeySchemaElement(KEY, KeyType.HASH))
            .withAttributeDefinitions(new AttributeDefinition(KEY, ScalarAttributeType.S))
            .withProvisionedThroughput(new ProvisionedThroughput(this.readCapacity, this.writeCapacity));

    this.dynamoDB.createTableAsync(createTableRequest,
            new AsyncHandler<CreateTableRequest, CreateTableResult>() {

                @Override
                public void onError(Exception e) {
                    logger.error(
                            "Cannot create DynamoDb table: " + DynamoDbMetaDataStore.this.table.getTableName(),
                            e);
                    DynamoDbMetaDataStore.this.createTableLatch.countDown();
                }

                @Override
                public void onSuccess(CreateTableRequest request, CreateTableResult createTableResult) {
                    Waiter<DescribeTableRequest> waiter = DynamoDbMetaDataStore.this.dynamoDB.waiters()
                            .tableExists();

                    WaiterParameters<DescribeTableRequest> waiterParameters = new WaiterParameters<>(
                            new DescribeTableRequest(DynamoDbMetaDataStore.this.table.getTableName()))
                                    .withPollingStrategy(new PollingStrategy(new MaxAttemptsRetryStrategy(25),
                                            new FixedDelayStrategy(1)));

                    waiter.runAsync(waiterParameters, new WaiterHandler<DescribeTableRequest>() {

                        @Override
                        public void onWaitSuccess(DescribeTableRequest request) {
                            DynamoDbMetaDataStore.this.createTableLatch.countDown();
                            DynamoDbMetaDataStore.this.table.describe();
                        }

                        @Override
                        public void onWaitFailure(Exception e) {
                            logger.error("Cannot describe DynamoDb table: "
                                    + DynamoDbMetaDataStore.this.table.getTableName(), e);
                            DynamoDbMetaDataStore.this.createTableLatch.countDown();
                        }

                    });
                }

            });
}

From source file:org.wildfly.camel.test.common.aws.KinesisUtils.java

License:Apache License

public static void createStream(AmazonKinesisClient client, String streamName) throws Exception {

    client.createStream(streamName, 1);/*  www .ja va 2 s.  com*/

    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);
}

From source file:org.wildfly.camel.test.common.aws.S3Utils.java

License:Apache License

@SuppressWarnings("unchecked")
public static void createBucket(AmazonS3Client client, String bucketName) throws Exception {

    client.createBucket(bucketName);//from  w w w.j ava2 s.  c o  m

    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);
}