com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClientBuilder Java Examples

The following examples show how to use com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClientBuilder. 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: DynamoDBClientPool.java    From geowave with Apache License 2.0 6 votes vote down vote up
public synchronized AmazonDynamoDBAsync getClient(final DynamoDBOptions options) {
  AmazonDynamoDBAsync client = clientCache.get(options);
  if (client == null) {

    if ((options.getRegion() == null)
        && ((options.getEndpoint() == null) || options.getEndpoint().isEmpty())) {
      throw new ParameterException("Compulsory to specify either the region or the endpoint");
    }

    final ClientConfiguration clientConfig = options.getClientConfig();
    final AmazonDynamoDBAsyncClientBuilder builder =
        AmazonDynamoDBAsyncClientBuilder.standard().withClientConfiguration(clientConfig);
    if ((options.getEndpoint() != null) && (options.getEndpoint().length() > 0)) {
      builder.withEndpointConfiguration(
          new EndpointConfiguration(
              options.getEndpoint(),
              options.getRegion() != null ? options.getRegion().getName() : "local"));
    } else {
      builder.withRegion(options.getRegion());
    }
    client = builder.build();
    clientCache.put(options, client);
  }
  return client;
}
 
Example #2
Source File: DynamoClient.java    From xyz-hub with Apache License 2.0 5 votes vote down vote up
DynamoClient(String tableArn) {
  arn = new ARN(tableArn);

  final AmazonDynamoDBAsyncClientBuilder builder = AmazonDynamoDBAsyncClientBuilder.standard();
  if (isLocal()) {
    builder.setCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("dummy", "dummy")));
    final String endpoint = String.format("http://%s:%s", arn.getRegion(), Integer.parseInt(arn.getAccountId()));
    builder.setEndpointConfiguration(new EndpointConfiguration(endpoint, "US-WEST-1"));
  }

  client = builder.build();
  db = new DynamoDB(client);
  tableName = new ARN(tableArn).getResourceWithoutType();
}
 
Example #3
Source File: AmazonAsyncDockerClientsHolder.java    From spring-localstack with Apache License 2.0 5 votes vote down vote up
@Override
public AmazonDynamoDBAsync amazonDynamoDB() {
    return decorateWithConfigsAndBuild(
        AmazonDynamoDBAsyncClientBuilder.standard(),
        LocalstackDocker::getEndpointDynamoDB
    );
}
 
Example #4
Source File: AwsTest.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
private static AmazonDynamoDBAsync buildAsyncClient() {
  final EndpointConfiguration endpointConfiguration = new EndpointConfiguration("http://localhost:8000", "us-west-2");
  final BasicAWSCredentials awsCreds = new BasicAWSCredentials("access_key_id", "secret_key_id");
  return AmazonDynamoDBAsyncClientBuilder
    .standard()
    .withEndpointConfiguration(endpointConfiguration)
    .withRequestHandlers()
    .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
    .withClientConfiguration(new ClientConfiguration().withConnectionTimeout(1))
    .build();
}
 
Example #5
Source File: KinesisBinderConfiguration.java    From spring-cloud-stream-binder-aws-kinesis with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public AmazonDynamoDBAsync dynamoDB() {
	if (this.hasInputs) {
		return AmazonDynamoDBAsyncClientBuilder.standard()
				.withCredentials(this.awsCredentialsProvider)
				.withRegion(this.region)
				.build();
	}
	else {
		return null;
	}
}
 
Example #6
Source File: ExtendedDockerTestUtils.java    From spring-cloud-stream-binder-aws-kinesis with Apache License 2.0 5 votes vote down vote up
public static AmazonDynamoDBAsync getClientDynamoDbAsync() {
	AmazonDynamoDBAsyncClientBuilder dynamoDBAsyncClientBuilder =
			AmazonDynamoDBAsyncClientBuilder.standard()
					.withEndpointConfiguration(
							createEndpointConfiguration(LocalstackDocker.INSTANCE::getEndpointDynamoDB));
	return applyConfigurationAndBuild(dynamoDBAsyncClientBuilder);
}
 
Example #7
Source File: AwsClientTracingTest.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
@Test
public void buildingAsyncClientWithEmptyConfigDoesNotThrowExceptions() {
  HttpTracing httpTracing = HttpTracing.create(tracing);
  environmentVariables.set("AWS_REGION", "us-east-1");

  AwsClientTracing.create(httpTracing).build(AmazonDynamoDBAsyncClientBuilder.standard());
}