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;
}
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);
}
}
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);
}
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(), "");
}
}
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;
}
Aggregations