use of com.amazonaws.Protocol in project elasticsearch by elastic.
the class InternalAwsS3Service method buildConfiguration.
// pkg private for tests
static ClientConfiguration buildConfiguration(Logger logger, Settings repositorySettings, Settings settings, String clientName, Integer maxRetries, String endpoint, boolean useThrottleRetries) {
ClientConfiguration clientConfiguration = new ClientConfiguration();
// the response metadata cache is only there for diagnostics purposes,
// but can force objects from every response to the old generation.
clientConfiguration.setResponseMetadataCacheSize(0);
Protocol protocol = getConfigValue(repositorySettings, settings, clientName, S3Repository.PROTOCOL_SETTING, S3Repository.Repository.PROTOCOL_SETTING, S3Repository.Repositories.PROTOCOL_SETTING);
clientConfiguration.setProtocol(protocol);
String proxyHost = getConfigValue(null, settings, clientName, S3Repository.PROXY_HOST_SETTING, null, CLOUD_S3.PROXY_HOST_SETTING);
if (Strings.hasText(proxyHost)) {
Integer proxyPort = getConfigValue(null, settings, clientName, S3Repository.PROXY_PORT_SETTING, null, CLOUD_S3.PROXY_PORT_SETTING);
try (SecureString proxyUsername = getConfigValue(null, settings, clientName, S3Repository.PROXY_USERNAME_SETTING, null, CLOUD_S3.PROXY_USERNAME_SETTING);
SecureString proxyPassword = getConfigValue(null, settings, clientName, S3Repository.PROXY_PASSWORD_SETTING, null, CLOUD_S3.PROXY_PASSWORD_SETTING)) {
clientConfiguration.withProxyHost(proxyHost).withProxyPort(proxyPort).withProxyUsername(proxyUsername.toString()).withProxyPassword(proxyPassword.toString());
}
}
if (maxRetries != null) {
// If not explicitly set, default to 3 with exponential backoff policy
clientConfiguration.setMaxErrorRetry(maxRetries);
}
clientConfiguration.setUseThrottleRetries(useThrottleRetries);
// #155: we might have 3rd party users using older S3 API version
String awsSigner = CLOUD_S3.SIGNER_SETTING.get(settings);
if (Strings.hasText(awsSigner)) {
logger.debug("using AWS API signer [{}]", awsSigner);
AwsSigner.configureSigner(awsSigner, clientConfiguration, endpoint);
}
TimeValue readTimeout = getConfigValue(null, settings, clientName, S3Repository.READ_TIMEOUT_SETTING, null, CLOUD_S3.READ_TIMEOUT);
clientConfiguration.setSocketTimeout((int) readTimeout.millis());
return clientConfiguration;
}
use of com.amazonaws.Protocol 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;
}
use of com.amazonaws.Protocol 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);
}
use of com.amazonaws.Protocol in project druid by druid-io.
the class S3StorageDruidModule method determineProtocol.
private static Protocol determineProtocol(AWSClientConfig clientConfig, AWSEndpointConfig endpointConfig) {
final Protocol protocolFromClientConfig = parseProtocol(clientConfig.getProtocol());
final String endpointUrl = endpointConfig.getUrl();
if (StringUtils.isNotEmpty(endpointUrl)) {
// noinspection ConstantConditions
final URI uri = URIs.parse(endpointUrl, protocolFromClientConfig.toString());
final Protocol protocol = parseProtocol(uri.getScheme());
if (protocol != null && (protocol != protocolFromClientConfig)) {
log.warn("[%s] protocol will be used for endpoint [%s]", protocol, endpointUrl);
}
return protocol;
} else {
return protocolFromClientConfig;
}
}
Aggregations