Search in sources :

Example 1 with ClientConfigurationFactory

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;
}
Also used : AmazonKinesisClient(com.amazonaws.services.kinesis.AmazonKinesisClient) ClientConfigurationFactory(com.amazonaws.ClientConfigurationFactory) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 2 with ClientConfigurationFactory

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());
}
Also used : ClientConfigurationFactory(com.amazonaws.ClientConfigurationFactory) Properties(java.util.Properties) ClientConfiguration(com.amazonaws.ClientConfiguration) AmazonKinesis(com.amazonaws.services.kinesis.AmazonKinesis) Test(org.junit.Test)

Example 3 with ClientConfigurationFactory

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;
}
Also used : AmazonDynamoDBStreamsAdapterClient(com.amazonaws.services.dynamodbv2.streamsadapter.AmazonDynamoDBStreamsAdapterClient) ClientConfigurationFactory(com.amazonaws.ClientConfigurationFactory) ClientConfiguration(com.amazonaws.ClientConfiguration) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider)

Example 4 with ClientConfigurationFactory

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);
}
Also used : ClientConfigurationFactory(com.amazonaws.ClientConfigurationFactory) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 5 with ClientConfigurationFactory

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);
}
Also used : AmazonS3ClientBuilder(com.amazonaws.services.s3.AmazonS3ClientBuilder) ClientConfigurationFactory(com.amazonaws.ClientConfigurationFactory) EndpointConfiguration(com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration) Protocol(com.amazonaws.Protocol) ClientConfiguration(com.amazonaws.ClientConfiguration) Provides(com.google.inject.Provides)

Aggregations

ClientConfiguration (com.amazonaws.ClientConfiguration)7 ClientConfigurationFactory (com.amazonaws.ClientConfigurationFactory)7 EndpointConfiguration (com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration)2 AmazonS3ClientBuilder (com.amazonaws.services.s3.AmazonS3ClientBuilder)2 Protocol (com.amazonaws.Protocol)1 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AmazonDynamoDBStreamsAdapterClient (com.amazonaws.services.dynamodbv2.streamsadapter.AmazonDynamoDBStreamsAdapterClient)1 AmazonKinesis (com.amazonaws.services.kinesis.AmazonKinesis)1 AmazonKinesisClient (com.amazonaws.services.kinesis.AmazonKinesisClient)1 Provides (com.google.inject.Provides)1 Properties (java.util.Properties)1 Test (org.junit.Test)1