Search in sources :

Example 51 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project eureka by Netflix.

the class AwsAsgUtil method getAmazonAutoScalingClient.

private AmazonAutoScaling getAmazonAutoScalingClient() {
    String aWSAccessId = serverConfig.getAWSAccessId();
    String aWSSecretKey = serverConfig.getAWSSecretKey();
    ClientConfiguration clientConfiguration = new ClientConfiguration().withConnectionTimeout(serverConfig.getASGQueryTimeoutMs());
    if (null != aWSAccessId && !"".equals(aWSAccessId) && null != aWSSecretKey && !"".equals(aWSSecretKey)) {
        return new AmazonAutoScalingClient(new BasicAWSCredentials(aWSAccessId, aWSSecretKey), clientConfiguration);
    } else {
        return new AmazonAutoScalingClient(new InstanceProfileCredentialsProvider(), clientConfiguration);
    }
}
Also used : InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) AmazonAutoScalingClient(com.amazonaws.services.autoscaling.AmazonAutoScalingClient) ClientConfiguration(com.amazonaws.ClientConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 52 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project simplejpa by appoxy.

the class EntityManagerFactoryImpl method createConfiguration.

private ClientConfiguration createConfiguration(boolean isSecure) {
    ClientConfiguration config = new ClientConfiguration();
    config.setUserAgent(USER_AGENT);
    Protocol protocol = isSecure ? Protocol.HTTPS : Protocol.HTTP;
    config.setProtocol(protocol);
    return config;
}
Also used : Protocol(com.amazonaws.Protocol) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 53 with ClientConfiguration

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

the class KinesisProxyTest method testClientConfigOverride.

@Test
public void testClientConfigOverride() {
    Properties configProps = new Properties();
    configProps.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1");
    configProps.setProperty(AWSUtil.AWS_CLIENT_CONFIG_PREFIX + "socketTimeout", "9999");
    KinesisProxyInterface proxy = KinesisProxy.create(configProps);
    AmazonKinesis kinesisClient = Whitebox.getInternalState(proxy, "kinesisClient");
    ClientConfiguration clientConfiguration = Whitebox.getInternalState(kinesisClient, "clientConfiguration");
    assertEquals(9999, clientConfiguration.getSocketTimeout());
}
Also used : Properties(java.util.Properties) ClientConfiguration(com.amazonaws.ClientConfiguration) AmazonKinesis(com.amazonaws.services.kinesis.AmazonKinesis) Test(org.junit.Test)

Example 54 with ClientConfiguration

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

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

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