Search in sources :

Example 56 with ClientConfiguration

use of com.amazonaws.ClientConfiguration 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 57 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project beam by apache.

the class AwsModuleTest method testAwsHttpClientConfigurationSerializationDeserialization.

@Test
public void testAwsHttpClientConfigurationSerializationDeserialization() throws Exception {
    ClientConfiguration clientConfiguration = new ClientConfiguration();
    clientConfiguration.setConnectionTimeout(100);
    clientConfiguration.setConnectionMaxIdleMillis(1000);
    clientConfiguration.setSocketTimeout(300);
    final String valueAsJson = objectMapper.writeValueAsString(clientConfiguration);
    final ClientConfiguration clientConfigurationDeserialized = objectMapper.readValue(valueAsJson, ClientConfiguration.class);
    assertEquals(100, clientConfigurationDeserialized.getConnectionTimeout());
    assertEquals(1000, clientConfigurationDeserialized.getConnectionMaxIdleMillis());
    assertEquals(300, clientConfigurationDeserialized.getSocketTimeout());
}
Also used : ClientConfiguration(com.amazonaws.ClientConfiguration) Test(org.junit.Test)

Example 58 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project beam by apache.

the class AwsModuleTest method testClientConfigurationSerializationDeserialization.

@Test
public void testClientConfigurationSerializationDeserialization() throws Exception {
    ClientConfiguration clientConfiguration = new ClientConfiguration();
    clientConfiguration.setProxyHost("localhost");
    clientConfiguration.setProxyPort(1234);
    clientConfiguration.setProxyUsername("username");
    clientConfiguration.setProxyPassword("password");
    final String valueAsJson = objectMapper.writeValueAsString(clientConfiguration);
    final ClientConfiguration valueDes = objectMapper.readValue(valueAsJson, ClientConfiguration.class);
    assertEquals("localhost", valueDes.getProxyHost());
    assertEquals(1234, valueDes.getProxyPort());
    assertEquals("username", valueDes.getProxyUsername());
    assertEquals("password", valueDes.getProxyPassword());
}
Also used : ClientConfiguration(com.amazonaws.ClientConfiguration) Test(org.junit.Test)

Example 59 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project jackrabbit by apache.

the class Utils method getClientConfiguration.

private static ClientConfiguration getClientConfiguration(Properties prop) {
    int connectionTimeOut = Integer.parseInt(prop.getProperty(S3Constants.S3_CONN_TIMEOUT));
    int socketTimeOut = Integer.parseInt(prop.getProperty(S3Constants.S3_SOCK_TIMEOUT));
    int maxConnections = Integer.parseInt(prop.getProperty(S3Constants.S3_MAX_CONNS));
    int maxErrorRetry = Integer.parseInt(prop.getProperty(S3Constants.S3_MAX_ERR_RETRY));
    String protocol = prop.getProperty(S3Constants.S3_CONN_PROTOCOL);
    String proxyHost = prop.getProperty(S3Constants.PROXY_HOST);
    String proxyPort = prop.getProperty(S3Constants.PROXY_PORT);
    ClientConfiguration cc = new ClientConfiguration();
    if (protocol != null && protocol.equalsIgnoreCase("http")) {
        cc.setProtocol(Protocol.HTTP);
    }
    if (proxyHost != null && !proxyHost.isEmpty()) {
        cc.setProxyHost(proxyHost);
    }
    if (proxyPort != null && !proxyPort.isEmpty()) {
        cc.setProxyPort(Integer.parseInt(proxyPort));
    }
    cc.setConnectionTimeout(connectionTimeOut);
    cc.setSocketTimeout(socketTimeOut);
    cc.setMaxConnections(maxConnections);
    cc.setMaxErrorRetry(maxErrorRetry);
    return cc;
}
Also used : ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 60 with ClientConfiguration

use of com.amazonaws.ClientConfiguration 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)134 Test (org.junit.Test)35 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)29 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)17 AWSCredentials (com.amazonaws.auth.AWSCredentials)14 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)13 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)13 AwsClientBuilder (com.amazonaws.client.builder.AwsClientBuilder)10 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)8 ClientConfigurationFactory (com.amazonaws.ClientConfigurationFactory)7 EnvVars (hudson.EnvVars)7 File (java.io.File)7 AmazonS3ClientBuilder (com.amazonaws.services.s3.AmazonS3ClientBuilder)6 Configuration (org.apache.hadoop.conf.Configuration)6 AmazonClientException (com.amazonaws.AmazonClientException)5 DefaultAWSCredentialsProviderChain (com.amazonaws.auth.DefaultAWSCredentialsProviderChain)5 EndpointConfiguration (com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration)5 URI (java.net.URI)5 Properties (java.util.Properties)5 Test (org.testng.annotations.Test)5