Example usage for com.amazonaws ClientConfiguration setConnectionTimeout

List of usage examples for com.amazonaws ClientConfiguration setConnectionTimeout

Introduction

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

Prototype

public void setConnectionTimeout(int connectionTimeout) 

Source Link

Document

Sets the amount of time to wait (in milliseconds) when initially establishing a connection before giving up and timing out.

Usage

From source file:br.puc_rio.ele.lvc.interimage.core.datamanager.AWSSource.java

License:Apache License

 public AWSSource(String accessKey, String secretKey, String bucket) {
   _accessKey = accessKey;//from w  w w .j  av  a2  s .  c  o  m
   _secretKey = secretKey;
   _bucket = bucket;
      
   AWSCredentials credentials = new BasicAWSCredentials(_accessKey, _secretKey);
      
   ClientConfiguration conf = new ClientConfiguration();
      
   conf.setConnectionTimeout(0);
   conf.setSocketTimeout(0);
      
   AmazonS3 conn = new AmazonS3Client(credentials);
   conn.setEndpoint("https://s3.amazonaws.com");
      
   _manager = new TransferManager(conn);
            
}

From source file:br.puc_rio.ele.lvc.interimage.core.datamanager.AWSSource.java

License:Apache License

public AWSSource(String accessKey, String secretKey, String bucket) {
        _accessKey = accessKey;//from  w  w w.  j  a v a  2s  .co m
        _secretKey = secretKey;
        _bucket = bucket;

        AWSCredentials credentials = new BasicAWSCredentials(_accessKey, _secretKey);

        ClientConfiguration conf = new ClientConfiguration();

        conf.setConnectionTimeout(0);
        conf.setSocketTimeout(0);

        AmazonS3 conn = new AmazonS3Client(credentials);
        conn.setEndpoint("https://s3.amazonaws.com");

        _manager = new TransferManager(conn);

    }

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());//ww w .j  a v a  2  s  . co m
    return config;
}

From source file:com.cloud.utils.S3Utils.java

License:Apache License

private static AmazonS3 acquireClient(final ClientOptions clientOptions) {

    final AWSCredentials credentials = new BasicAWSCredentials(clientOptions.getAccessKey(),
            clientOptions.getSecretKey());

    final ClientConfiguration configuration = new ClientConfiguration();

    if (clientOptions.isHttps() != null) {
        configuration.setProtocol(clientOptions.isHttps() == true ? HTTPS : HTTP);
    }/*  w  ww.ja v  a  2s .co m*/

    if (clientOptions.getConnectionTimeout() != null) {
        configuration.setConnectionTimeout(clientOptions.getConnectionTimeout());
    }

    if (clientOptions.getMaxErrorRetry() != null) {
        configuration.setMaxErrorRetry(clientOptions.getMaxErrorRetry());
    }

    if (clientOptions.getSocketTimeout() != null) {
        configuration.setSocketTimeout(clientOptions.getSocketTimeout());
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(format(
                "Creating S3 client with configuration: [protocol: %1$s, connectionTimeOut: "
                        + "%2$s, maxErrorRetry: %3$s, socketTimeout: %4$s]",
                configuration.getProtocol(), configuration.getConnectionTimeout(),
                configuration.getMaxErrorRetry(), configuration.getSocketTimeout()));
    }

    final AmazonS3Client client = new AmazonS3Client(credentials, configuration);

    if (isNotBlank(clientOptions.getEndPoint())) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(format("Setting the end point for S3 client %1$s to %2$s.", client,
                    clientOptions.getEndPoint()));
        }
        client.setEndpoint(clientOptions.getEndPoint());
    }

    return client;

}

From source file:com.eucalyptus.objectstorage.client.GenericS3ClientFactory.java

License:Open Source License

protected static ClientConfiguration getDefaultConfiguration(boolean withHttps) {
    ClientConfiguration config = new ClientConfiguration();
    config.setConnectionTimeout(CONNECTION_TIMEOUT_MS);
    config.setMaxConnections(DEFAULT_MAX_CONNECTIONS);
    config.setMaxErrorRetry(DEFAULT_MAX_ERROR_RETRY);
    config.setUseReaper(true);/*from  ww w . j a  v  a 2s  .co  m*/
    config.setSocketTimeout(DEFAULT_SOCKET_READ_TIMEOUT_MS);
    config.setProtocol(withHttps ? Protocol.HTTPS : Protocol.HTTP);
    return config;
}

From source file:com.eucalyptus.objectstorage.client.OsgInternalS3Client.java

License:Open Source License

private synchronized void initializeNewClient(@Nonnull AWSCredentials credentials, @Nonnull String endpoint,
        @Nonnull Boolean https, @Nonnull Boolean useDns) {
    ClientConfiguration config = new ClientConfiguration();
    config.setConnectionTimeout(CONNECTION_TIMEOUT_MS); //very short timeout
    config.setSocketTimeout(OSG_SOCKET_TIMEOUT_MS);
    config.setUseReaper(true);/*from w w w.  j  av  a  2 s .  co  m*/
    config.setMaxConnections(OSG_MAX_CONNECTIONS);
    Protocol protocol = https ? Protocol.HTTPS : Protocol.HTTP;
    config.setProtocol(protocol);
    this.clientConfig = config;
    this.s3Client = new AmazonS3Client(credentials, config);
    this.ops = new S3ClientOptions().withPathStyleAccess(!useDns);
    this.s3Client.setS3ClientOptions(ops);
    this.instantiated = new Date();
    this.currentCredentials = credentials;
    this.setS3Endpoint(endpoint);
}

From source file:com.eucalyptus.simpleworkflow.common.client.WorkflowClientStandalone.java

License:Open Source License

private ClientConfiguration buildClientConfig() {
    final ClientConfiguration configuration = new ClientConfiguration();
    configuration.setConnectionTimeout(this.clientConnectionTimeout);
    configuration.setMaxConnections(this.clientMaxConnections);
    return configuration;
}

From source file:com.facebook.presto.hive.PrestoS3FileSystem.java

License:Apache License

@Override
public void initialize(URI uri, Configuration conf) throws IOException {
    checkNotNull(uri, "uri is null");
    checkNotNull(conf, "conf is null");

    this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority());
    this.workingDirectory = new Path("/").makeQualified(this.uri, new Path("/"));

    HiveClientConfig defaults = new HiveClientConfig();
    this.stagingDirectory = new File(
            conf.get(S3_STAGING_DIRECTORY, defaults.getS3StagingDirectory().toString()));
    this.maxClientRetries = conf.getInt(S3_MAX_CLIENT_RETRIES, defaults.getS3MaxClientRetries());
    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()));

    ClientConfiguration configuration = new ClientConfiguration();
    configuration.setMaxErrorRetry(maxErrorRetries);
    configuration.setProtocol(sslEnabled ? Protocol.HTTPS : Protocol.HTTP);
    configuration.setConnectionTimeout(Ints.checkedCast(connectTimeout.toMillis()));

    this.s3 = new AmazonS3Client(getAwsCredentials(uri, conf), configuration);
}

From source file:com.ibm.stocator.fs.cos.COSAPIClient.java

License:Apache License

/**
 * Initializes connection management/* ww  w.jav  a2  s  .com*/
 *
 * @param conf Hadoop configuration
 * @param clientConf client SDK configuration
 */
private void initConnectionSettings(Configuration conf, ClientConfiguration clientConf) throws IOException {
    clientConf.setMaxConnections(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, MAXIMUM_CONNECTIONS, DEFAULT_MAXIMUM_CONNECTIONS));
    clientConf.setClientExecutionTimeout(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, CLIENT_EXEC_TIMEOUT, DEFAULT_CLIENT_EXEC_TIMEOUT));
    clientConf.setMaxErrorRetry(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, MAX_ERROR_RETRIES, DEFAULT_MAX_ERROR_RETRIES));
    clientConf.setConnectionTimeout(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, ESTABLISH_TIMEOUT, DEFAULT_ESTABLISH_TIMEOUT));
    clientConf
            .setSocketTimeout(Utils.getInt(conf, FS_COS, FS_ALT_KEYS, SOCKET_TIMEOUT, DEFAULT_SOCKET_TIMEOUT));
    clientConf.setRequestTimeout(
            Utils.getInt(conf, FS_COS, FS_ALT_KEYS, REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT));
    int sockSendBuffer = Utils.getInt(conf, FS_COS, FS_ALT_KEYS, SOCKET_SEND_BUFFER,
            DEFAULT_SOCKET_SEND_BUFFER);
    int sockRecvBuffer = Utils.getInt(conf, FS_COS, FS_ALT_KEYS, SOCKET_RECV_BUFFER,
            DEFAULT_SOCKET_RECV_BUFFER);
    clientConf.setSocketBufferSizeHints(sockSendBuffer, sockRecvBuffer);
    String signerOverride = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, SIGNING_ALGORITHM, "");
    if (!signerOverride.isEmpty()) {
        LOG.debug("Signer override = {}", signerOverride);
        clientConf.setSignerOverride(signerOverride);
    }

    String userAgentPrefix = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, USER_AGENT_PREFIX,
            DEFAULT_USER_AGENT_PREFIX);
    String userAgentName = singletoneInitTimeData.getUserAgentName();
    if (!userAgentPrefix.equals(DEFAULT_USER_AGENT_PREFIX)) {
        userAgentName = userAgentPrefix + " " + userAgentName;
    }
    clientConf.setUserAgentPrefix(userAgentName);
}

From source file:com.liferay.portal.store.s3.S3Store.java

License:Open Source License

protected ClientConfiguration getClientConfiguration() {
    ClientConfiguration clientConfiguration = new ClientConfiguration();

    clientConfiguration.setConnectionTimeout(_s3StoreConfiguration.connectionTimeout());

    clientConfiguration.setMaxErrorRetry(_s3StoreConfiguration.httpClientMaxErrorRetry());
    clientConfiguration.setMaxConnections(_s3StoreConfiguration.httpClientMaxConnections());

    configureProxySettings(clientConfiguration);

    return clientConfiguration;
}