Search in sources :

Example 26 with ClientConfiguration

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;
}
Also used : ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 27 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)

Example 28 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 29 with ClientConfiguration

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();
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) AmazonSQSClientBuilder(com.amazonaws.services.sqs.AmazonSQSClientBuilder) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 30 with ClientConfiguration

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;
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) AwsClientBuilder(com.amazonaws.client.builder.AwsClientBuilder) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Aggregations

ClientConfiguration (com.amazonaws.ClientConfiguration)44 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)18 AWSCredentials (com.amazonaws.auth.AWSCredentials)12 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)6 AmazonClientException (com.amazonaws.AmazonClientException)3 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)3 AmazonDynamoDBClient (com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient)3 File (java.io.File)3 Configuration (org.apache.hadoop.conf.Configuration)3 Test (org.testng.annotations.Test)3 AmazonServiceException (com.amazonaws.AmazonServiceException)2 Protocol (com.amazonaws.Protocol)2 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)2 InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)2 AwsClientBuilder (com.amazonaws.client.builder.AwsClientBuilder)2 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)2 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)2 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 S3ClientOptions (com.amazonaws.services.s3.S3ClientOptions)2 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)2