Example usage for com.amazonaws ClientConfiguration setUseGzip

List of usage examples for com.amazonaws ClientConfiguration setUseGzip

Introduction

In this page you can find the example usage for com.amazonaws ClientConfiguration setUseGzip.

Prototype

public void setUseGzip(boolean use) 

Source Link

Document

Sets whether gzip compression should be used

Usage

From source file:com.amazon.kinesis.streaming.agent.AgentContext.java

License:Open Source License

public ClientConfiguration getAwsClientConfiguration() {
    ClientConfiguration config = new ClientConfiguration();
    config.setUserAgent(userAgent(config));
    config.setMaxConnections(maxConnections());
    config.setConnectionTimeout(connectionTimeoutMillis());
    config.setSocketTimeout(socketTimeoutMillis());
    config.setUseTcpKeepAlive(useTcpKeepAlive());
    config.setConnectionTTL(connectionTTLMillis());
    config.setUseGzip(useHttpGzip());
    return config;
}

From source file:com.netflix.spinnaker.clouddriver.aws.security.AmazonClientProvider.java

License:Apache License

protected <T extends AmazonWebServiceClient> T getClient(Class<T> impl,
        AWSCredentialsProvider awsCredentialsProvider, String region) {
    checkAWSCredentialsProvider(awsCredentialsProvider);
    try {/* ww w  . j  a  v a  2 s .  c  o  m*/
        Constructor<T> constructor = impl.getConstructor(AWSCredentialsProvider.class,
                ClientConfiguration.class);

        ClientConfiguration clientConfiguration = new ClientConfiguration();

        if (awsCredentialsProvider instanceof NetflixSTSAssumeRoleSessionCredentialsProvider) {
            RetryPolicy.RetryCondition delegatingRetryCondition = (originalRequest, exception,
                    retriesAttempted) -> {
                NetflixSTSAssumeRoleSessionCredentialsProvider stsCredentialsProvider = (NetflixSTSAssumeRoleSessionCredentialsProvider) awsCredentialsProvider;
                if (exception instanceof AmazonServiceException) {
                    ((AmazonServiceException) exception).getHttpHeaders().put("targetAccountId",
                            stsCredentialsProvider.getAccountId());
                }
                return retryPolicy.getRetryCondition().shouldRetry(originalRequest, exception,
                        retriesAttempted);
            };

            RetryPolicy delegatingRetryPolicy = new RetryPolicy(delegatingRetryCondition,
                    retryPolicy.getBackoffStrategy(), retryPolicy.getMaxErrorRetry(),
                    retryPolicy.isMaxErrorRetryInClientConfigHonored());
            clientConfiguration.setRetryPolicy(delegatingRetryPolicy);
        } else {
            clientConfiguration.setRetryPolicy(retryPolicy);
        }

        if (proxy != null && proxy.isProxyConfigMode()) {
            proxy.apply(clientConfiguration);
        }

        clientConfiguration.setUseGzip(useGzip);

        T delegate = constructor.newInstance(awsCredentialsProvider, clientConfiguration);
        for (RequestHandler2 requestHandler : requestHandlers) {
            delegate.addRequestHandler(requestHandler);
        }
        if (region != null && region.length() > 0) {
            delegate.setRegion(Region.getRegion(Regions.fromName(region)));
        }
        return delegate;
    } catch (Exception e) {
        throw new RuntimeException("Instantiation of client implementation failed!", e);
    }
}

From source file:com.smoketurner.pipeline.application.config.AwsConfiguration.java

License:Apache License

@JsonIgnore
public ClientConfiguration getClientConfiguration() {
    final ClientConfiguration clientConfig = new ClientConfiguration();
    if (proxy.isPresent()) {
        clientConfig.setProxyHost(proxy.get().getHostText());
        clientConfig.setProxyPort(proxy.get().getPort());
    }/*w  w w .  j  a va  2s  .  co  m*/
    clientConfig.setUseTcpKeepAlive(true);
    // needs to be false to support streaming gunzipping
    clientConfig.setUseGzip(false);
    return clientConfig;
}

From source file:io.fineo.drill.exec.store.dynamo.config.ClientProperties.java

License:Apache License

@JsonIgnore
public ClientConfiguration getConfiguration() {
    ClientConfiguration clientConfig = new ClientConfiguration();
    if (connectionTimeout > 0) {
        clientConfig.withClientExecutionTimeout(connectionTimeout);
    }/* w  ww .j av  a2  s.  co m*/
    if (maxConnections > 0) {
        clientConfig.withMaxConnections(maxConnections);
    }
    if (maxErrorRetry > 0) {
        clientConfig.withMaxErrorRetry(maxErrorRetry);
    }
    if (socketTimeout > 0) {
        clientConfig.withSocketTimeout(socketTimeout);
    }
    clientConfig.withSocketBufferSizeHints(socketSendBufferHint, socketReceiveBufferHint);
    if (withGzip != null) {
        clientConfig.setUseGzip(withGzip.booleanValue());
    }
    if (withReaper != null) {
        clientConfig.setUseReaper(withReaper.booleanValue());
    }

    return clientConfig;
}

From source file:org.geowebcache.s3.S3BlobStoreConfig.java

License:Open Source License

/**
 * @return {@link AmazonS3Client} constructed from this {@link S3BlobStoreConfig}.
 *//*  w w  w  .j  a v a  2s . c  o m*/
public AmazonS3Client buildClient() {
    AWSCredentials awsCredentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey);
    ClientConfiguration clientConfig = new ClientConfiguration();
    if (null != useHTTPS) {
        clientConfig.setProtocol(useHTTPS ? Protocol.HTTPS : Protocol.HTTP);
    }
    if (null != maxConnections && maxConnections > 0) {
        clientConfig.setMaxConnections(maxConnections);
    }
    clientConfig.setProxyDomain(proxyDomain);
    clientConfig.setProxyWorkstation(proxyWorkstation);
    clientConfig.setProxyHost(proxyHost);
    if (null != proxyPort) {
        clientConfig.setProxyPort(proxyPort);
    }
    clientConfig.setProxyUsername(proxyUsername);
    clientConfig.setProxyPassword(proxyPassword);
    if (null != useGzip) {
        clientConfig.setUseGzip(useGzip);
    }
    log.debug("Initializing AWS S3 connection");
    return new AmazonS3Client(awsCredentials, clientConfig);
}

From source file:org.geowebcache.s3.S3BlobStoreInfo.java

License:Open Source License

/** @return {@link AmazonS3Client} constructed from this {@link S3BlobStoreInfo}. */
public AmazonS3Client buildClient() {
    ClientConfiguration clientConfig = new ClientConfiguration();
    if (null != useHTTPS) {
        clientConfig.setProtocol(useHTTPS ? Protocol.HTTPS : Protocol.HTTP);
    }/*from   ww w .  j  a  v  a  2s .  c o m*/
    if (null != maxConnections && maxConnections > 0) {
        clientConfig.setMaxConnections(maxConnections);
    }
    clientConfig.setProxyDomain(proxyDomain);
    clientConfig.setProxyWorkstation(proxyWorkstation);
    clientConfig.setProxyHost(proxyHost);
    if (null != proxyPort) {
        clientConfig.setProxyPort(proxyPort);
    }
    clientConfig.setProxyUsername(proxyUsername);
    clientConfig.setProxyPassword(proxyPassword);
    if (null != useGzip) {
        clientConfig.setUseGzip(useGzip);
    }
    log.debug("Initializing AWS S3 connection");
    AmazonS3Client client = new AmazonS3Client(getCredentialsProvider(), clientConfig);
    if (endpoint != null && !"".equals(endpoint)) {
        S3ClientOptions s3ClientOptions = new S3ClientOptions();
        s3ClientOptions.setPathStyleAccess(true);
        client.setS3ClientOptions(s3ClientOptions);
        client.setEndpoint(endpoint);
    }
    if (!client.doesBucketExist(bucket)) {
        client.createBucket(bucket);
    }
    return client;
}