Search in sources :

Example 16 with ClientConfiguration

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

the class AWSClient method sdbClient.

/**
     * Amazon SimpleDB client.
     *
     * @return the Amazon SimpleDB client
     */
public AmazonSimpleDB sdbClient() {
    AmazonSimpleDB client;
    ClientConfiguration cc = awsClientConfig;
    if (cc == null) {
        cc = new ClientConfiguration();
        cc.setMaxErrorRetry(SIMPLE_DB_MAX_RETRY);
    }
    if (awsCredentialsProvider == null) {
        client = new AmazonSimpleDBClient(cc);
    } else {
        client = new AmazonSimpleDBClient(awsCredentialsProvider, cc);
    }
    // http://docs.amazonwebservices.com/general/latest/gr/rande.html#sdb_region
    if (region == null || region.equals("us-east-1")) {
        client.setEndpoint("sdb.amazonaws.com");
    } else {
        client.setEndpoint("sdb." + region + ".amazonaws.com");
    }
    return client;
}
Also used : AmazonSimpleDBClient(com.amazonaws.services.simpledb.AmazonSimpleDBClient) AmazonSimpleDB(com.amazonaws.services.simpledb.AmazonSimpleDB) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 17 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 18 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project presto by prestodb.

the class PrestoS3FileSystem method initialize.

@Override
public void initialize(URI uri, Configuration conf) throws IOException {
    requireNonNull(uri, "uri is null");
    requireNonNull(conf, "conf is null");
    super.initialize(uri, conf);
    setConf(conf);
    this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority());
    this.workingDirectory = new Path(PATH_SEPARATOR).makeQualified(this.uri, new Path(PATH_SEPARATOR));
    HiveS3Config defaults = new HiveS3Config();
    this.stagingDirectory = new File(conf.get(S3_STAGING_DIRECTORY, defaults.getS3StagingDirectory().toString()));
    this.maxAttempts = conf.getInt(S3_MAX_CLIENT_RETRIES, defaults.getS3MaxClientRetries()) + 1;
    this.maxBackoffTime = Duration.valueOf(conf.get(S3_MAX_BACKOFF_TIME, defaults.getS3MaxBackoffTime().toString()));
    this.maxRetryTime = Duration.valueOf(conf.get(S3_MAX_RETRY_TIME, defaults.getS3MaxRetryTime().toString()));
    int maxErrorRetries = conf.getInt(S3_MAX_ERROR_RETRIES, defaults.getS3MaxErrorRetries());
    boolean sslEnabled = conf.getBoolean(S3_SSL_ENABLED, defaults.isS3SslEnabled());
    Duration connectTimeout = Duration.valueOf(conf.get(S3_CONNECT_TIMEOUT, defaults.getS3ConnectTimeout().toString()));
    Duration socketTimeout = Duration.valueOf(conf.get(S3_SOCKET_TIMEOUT, defaults.getS3SocketTimeout().toString()));
    int maxConnections = conf.getInt(S3_MAX_CONNECTIONS, defaults.getS3MaxConnections());
    long minFileSize = conf.getLong(S3_MULTIPART_MIN_FILE_SIZE, defaults.getS3MultipartMinFileSize().toBytes());
    long minPartSize = conf.getLong(S3_MULTIPART_MIN_PART_SIZE, defaults.getS3MultipartMinPartSize().toBytes());
    this.useInstanceCredentials = conf.getBoolean(S3_USE_INSTANCE_CREDENTIALS, defaults.isS3UseInstanceCredentials());
    this.pinS3ClientToCurrentRegion = conf.getBoolean(S3_PIN_CLIENT_TO_CURRENT_REGION, defaults.isPinS3ClientToCurrentRegion());
    this.sseEnabled = conf.getBoolean(S3_SSE_ENABLED, defaults.isS3SseEnabled());
    this.sseType = PrestoS3SseType.valueOf(conf.get(S3_SSE_TYPE, defaults.getS3SseType().name()));
    this.sseKmsKeyId = conf.get(S3_SSE_KMS_KEY_ID, defaults.getS3SseKmsKeyId());
    String userAgentPrefix = conf.get(S3_USER_AGENT_PREFIX, defaults.getS3UserAgentPrefix());
    ClientConfiguration configuration = new ClientConfiguration().withMaxErrorRetry(maxErrorRetries).withProtocol(sslEnabled ? Protocol.HTTPS : Protocol.HTTP).withConnectionTimeout(toIntExact(connectTimeout.toMillis())).withSocketTimeout(toIntExact(socketTimeout.toMillis())).withMaxConnections(maxConnections).withUserAgentPrefix(userAgentPrefix).withUserAgentSuffix(S3_USER_AGENT_SUFFIX);
    this.s3 = createAmazonS3Client(uri, conf, configuration);
    transferConfig.setMultipartUploadThreshold(minFileSize);
    transferConfig.setMinimumUploadPartSize(minPartSize);
}
Also used : Path(org.apache.hadoop.fs.Path) Duration(io.airlift.units.Duration) File(java.io.File) Files.createTempFile(java.nio.file.Files.createTempFile) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 19 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project presto by prestodb.

the class TestPrestoS3FileSystem method testDefaultS3ClientConfiguration.

@Test
public void testDefaultS3ClientConfiguration() throws Exception {
    HiveS3Config defaults = new HiveS3Config();
    try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
        fs.initialize(new URI("s3n://test-bucket/"), new Configuration());
        ClientConfiguration config = getFieldValue(fs.getS3Client(), AmazonWebServiceClient.class, "clientConfiguration", ClientConfiguration.class);
        assertEquals(config.getMaxErrorRetry(), defaults.getS3MaxErrorRetries());
        assertEquals(config.getConnectionTimeout(), defaults.getS3ConnectTimeout().toMillis());
        assertEquals(config.getSocketTimeout(), defaults.getS3SocketTimeout().toMillis());
        assertEquals(config.getMaxConnections(), defaults.getS3MaxConnections());
        assertEquals(config.getUserAgentSuffix(), S3_USER_AGENT_SUFFIX);
        assertEquals(config.getUserAgentPrefix(), "");
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ClientConfiguration(com.amazonaws.ClientConfiguration) URI(java.net.URI) ClientConfiguration(com.amazonaws.ClientConfiguration) Test(org.testng.annotations.Test)

Example 20 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project exhibitor by soabase.

the class PropertyBasedS3ClientConfig method getAWSClientConfig.

@Override
public ClientConfiguration getAWSClientConfig() {
    ClientConfiguration awsClientConfig = new ClientConfiguration();
    awsClientConfig.setProxyHost(proxyHost);
    awsClientConfig.setProxyPort(proxyPort);
    if (proxyUsername != null) {
        awsClientConfig.setProxyUsername(proxyUsername);
    }
    if (proxyPassword != null) {
        awsClientConfig.setProxyPassword(proxyPassword);
    }
    return awsClientConfig;
}
Also used : ClientConfiguration(com.amazonaws.ClientConfiguration)

Aggregations

ClientConfiguration (com.amazonaws.ClientConfiguration)42 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)17 AWSCredentials (com.amazonaws.auth.AWSCredentials)13 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)5 AmazonDynamoDBClient (com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient)4 Configuration (org.apache.hadoop.conf.Configuration)4 PropertiesCredentials (com.amazonaws.auth.PropertiesCredentials)3 File (java.io.File)3 Test (org.testng.annotations.Test)3 AmazonClientException (com.amazonaws.AmazonClientException)2 Protocol (com.amazonaws.Protocol)2 InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)2 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)2 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 S3ClientOptions (com.amazonaws.services.s3.S3ClientOptions)2 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)2 AmazonSimpleDB (com.amazonaws.services.simpledb.AmazonSimpleDB)2 AmazonSimpleDBClient (com.amazonaws.services.simpledb.AmazonSimpleDBClient)2 URI (java.net.URI)2 Date (java.util.Date)2