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;
}
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;
}
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 opennms by OpenNMS.
the class DefaultAmazonSQSManager method createSQSClient.
private AmazonSQS createSQSClient() {
final AmazonSQSClientBuilder builder = AmazonSQSClientBuilder.standard().withRegion(sqsConfig.getRegion());
if (sqsConfig.hasStaticCredentials()) {
final BasicAWSCredentials awsCreds = new BasicAWSCredentials(sqsConfig.getAccessKey(), sqsConfig.getSecretKey());
builder.withCredentials(new AWSStaticCredentialsProvider(awsCreds));
}
if (sqsConfig.isUseHttp()) {
final ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProtocol(Protocol.HTTP);
builder.withClientConfiguration(clientConfig);
}
return builder.build();
}
use of com.amazonaws.ClientConfiguration in project cas by apereo.
the class DynamoDbCloudConfigBootstrapConfiguration method getAmazonDynamoDbClient.
private static AmazonDynamoDB getAmazonDynamoDbClient(final Environment environment) {
final ClientConfiguration cfg = new ClientConfiguration();
try {
final String localAddress = getSetting(environment, "localAddress");
if (StringUtils.isNotBlank(localAddress)) {
cfg.setLocalAddress(InetAddress.getByName(localAddress));
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
final String key = getSetting(environment, "credentialAccessKey");
final String secret = getSetting(environment, "credentialSecretKey");
final AWSCredentials credentials = new BasicAWSCredentials(key, secret);
String region = getSetting(environment, "region");
if (StringUtils.isBlank(region)) {
region = Regions.getCurrentRegion().getName();
}
String regionOverride = getSetting(environment, "regionOverride");
if (StringUtils.isNotBlank(regionOverride)) {
regionOverride = Regions.getCurrentRegion().getName();
}
final String endpoint = getSetting(environment, "endpoint");
final AmazonDynamoDB client = AmazonDynamoDBClient.builder().withCredentials(new AWSStaticCredentialsProvider(credentials)).withClientConfiguration(cfg).withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, regionOverride)).withRegion(region).build();
return client;
}
Aggregations