use of com.amazonaws.ClientConfigurationFactory in project flink by apache.
the class AWSUtil method createKinesisClient.
/**
* Creates an Amazon Kinesis Client.
* @param configProps configuration properties containing the access key, secret key, and region
* @return a new Amazon Kinesis Client
*/
public static AmazonKinesisClient createKinesisClient(Properties configProps) {
// set a Flink-specific user agent
ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
awsClientConfig.setUserAgent("Apache Flink " + EnvironmentInformation.getVersion() + " (" + EnvironmentInformation.getRevisionInformation().commitId + ") Kinesis Connector");
// utilize automatic refreshment of credentials by directly passing the AWSCredentialsProvider
AmazonKinesisClient client = new AmazonKinesisClient(AWSUtil.getCredentialsProvider(configProps), awsClientConfig);
client.setRegion(Region.getRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION))));
if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) {
client.setEndpoint(configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT));
}
return client;
}
use of com.amazonaws.ClientConfigurationFactory in project flink by apache.
the class KinesisProxyTest method testCustomConfigurationOverride.
@Test
public void testCustomConfigurationOverride() {
Properties configProps = new Properties();
configProps.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1");
KinesisProxy proxy = new KinesisProxy(configProps) {
@Override
protected AmazonKinesis createKinesisClient(Properties configProps) {
ClientConfiguration clientConfig = new ClientConfigurationFactory().getConfig();
clientConfig.setSocketTimeout(10000);
return AWSUtil.createKinesisClient(configProps, clientConfig);
}
};
AmazonKinesis kinesisClient = Whitebox.getInternalState(proxy, "kinesisClient");
ClientConfiguration clientConfiguration = Whitebox.getInternalState(kinesisClient, "clientConfiguration");
assertEquals(10000, clientConfiguration.getSocketTimeout());
}
use of com.amazonaws.ClientConfigurationFactory in project flink by apache.
the class DynamoDBStreamsProxy method createKinesisClient.
/**
* Creates an AmazonDynamoDBStreamsAdapterClient. Uses it as the internal client interacting
* with the DynamoDB streams.
*
* @param configProps configuration properties
* @return an AWS DynamoDB streams adapter client
*/
@Override
protected AmazonKinesis createKinesisClient(Properties configProps) {
ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
setAwsClientConfigProperties(awsClientConfig, configProps);
AWSCredentialsProvider credentials = getCredentialsProvider(configProps);
awsClientConfig.setUserAgentPrefix(String.format(USER_AGENT_FORMAT, EnvironmentInformation.getVersion(), EnvironmentInformation.getRevisionInformation().commitId));
AmazonDynamoDBStreamsAdapterClient adapterClient = new AmazonDynamoDBStreamsAdapterClient(credentials, awsClientConfig);
if (configProps.containsKey(AWS_ENDPOINT)) {
adapterClient.setEndpoint(configProps.getProperty(AWS_ENDPOINT));
} else {
adapterClient.setRegion(Region.getRegion(Regions.fromName(configProps.getProperty(AWS_REGION))));
}
return adapterClient;
}
use of com.amazonaws.ClientConfigurationFactory in project flink by apache.
the class KinesisProxy method createKinesisClient.
/**
* Create the Kinesis client, using the provided configuration properties and default {@link
* ClientConfiguration}. Derived classes can override this method to customize the client
* configuration.
*/
protected AmazonKinesis createKinesisClient(Properties configProps) {
ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
AWSUtil.setAwsClientConfigProperties(awsClientConfig, configProps);
return AWSUtil.createKinesisClient(configProps, awsClientConfig);
}
use of com.amazonaws.ClientConfigurationFactory in project druid by druid-io.
the class S3StorageDruidModule method getServerSideEncryptingAmazonS3Builder.
// This provides ServerSideEncryptingAmazonS3.Builder with default configs from Guice injection initially set.
// However, this builder can then be modified and have configuration(s) inside
// AmazonS3ClientBuilder and/or S3StorageConfig overridden before being built.
@Provides
public ServerSideEncryptingAmazonS3.Builder getServerSideEncryptingAmazonS3Builder(AWSCredentialsProvider provider, AWSProxyConfig proxyConfig, AWSEndpointConfig endpointConfig, AWSClientConfig clientConfig, S3StorageConfig storageConfig) {
final ClientConfiguration configuration = new ClientConfigurationFactory().getConfig();
final Protocol protocol = determineProtocol(clientConfig, endpointConfig);
final AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3Client.builder().withCredentials(provider).withClientConfiguration(setProxyConfig(configuration, proxyConfig).withProtocol(protocol)).withChunkedEncodingDisabled(clientConfig.isDisableChunkedEncoding()).withPathStyleAccessEnabled(clientConfig.isEnablePathStyleAccess()).withForceGlobalBucketAccessEnabled(clientConfig.isForceGlobalBucketAccessEnabled());
if (StringUtils.isNotEmpty(endpointConfig.getUrl())) {
amazonS3ClientBuilder.setEndpointConfiguration(new EndpointConfiguration(endpointConfig.getUrl(), endpointConfig.getSigningRegion()));
}
return ServerSideEncryptingAmazonS3.builder().setAmazonS3ClientBuilder(amazonS3ClientBuilder).setS3StorageConfig(storageConfig);
}
Aggregations