com.amazonaws.waiters.Waiter.runAsync()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中com.amazonaws.waiters.Waiter.runAsync()方法的一些代码示例,展示了Waiter.runAsync()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Waiter.runAsync()方法的具体详情如下:
包路径:com.amazonaws.waiters.Waiter
类名称:Waiter
方法名:runAsync

Waiter.runAsync介绍

[英]Polls asynchronously until it is determined that the resource transitioned into the desired state or not. Includes additional callback.
[中]

代码示例

代码示例来源:origin: wildfly-extras/wildfly-camel

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

代码示例来源:origin: org.wildfly.camel/wildfly-camel-itests-common

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

代码示例来源:origin: wildfly-extras/wildfly-camel

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

代码示例来源:origin: org.wildfly.camel/wildfly-camel-itests-common

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

代码示例来源:origin: jenkinsci/pipeline-aws-plugin

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

代码示例来源:origin: jenkinsci/pipeline-aws-plugin

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

代码示例来源:origin: spring-projects/spring-integration-aws

@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(DynamoDbMetadataStore.this.createTableRetries),
                  new FixedDelayStrategy(DynamoDbMetadataStore.this.createTableDelay)));
  waiter.runAsync(waiterParameters, new WaiterHandler<DescribeTableRequest>() {
    @Override
    public void onWaitSuccess(DescribeTableRequest request) {
      updateTimeToLiveIfAny();
      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();
    }
  });
}

代码示例来源:origin: org.springframework.integration/spring-integration-aws

@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(DynamoDbMetadataStore.this.createTableRetries),
                  new FixedDelayStrategy(DynamoDbMetadataStore.this.createTableDelay)));
  waiter.runAsync(waiterParameters, new WaiterHandler<DescribeTableRequest>() {
    @Override
    public void onWaitSuccess(DescribeTableRequest request) {
      updateTimeToLiveIfAny();
      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();
    }
  });
}

相关文章