Example usage for com.amazonaws ClientConfiguration setMaxConnections

List of usage examples for com.amazonaws ClientConfiguration setMaxConnections

Introduction

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

Prototype

public void setMaxConnections(int maxConnections) 

Source Link

Document

Sets the maximum number of allowed open HTTP connections.

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

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 w  ww.j  a  va 2s . c o  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);// w w  w  .j a  v a2s . com
    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.ibm.stocator.fs.cos.COSAPIClient.java

License:Apache License

/**
 * Initializes connection management//  w w w .java2  s  .  co  m
 *
 * @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.intuit.tank.vmManager.environment.amazon.CloudwatchInstance.java

License:Open Source License

/**
 * /*from w  w w  .j  a v a 2s .  com*/
 * @param request
 * @param vmRegion
 */
public CloudwatchInstance(VMRegion vmRegion) {
    // In case vmRegion is passed as null, use default region from settings file
    if (vmRegion == null) {
        vmRegion = config.getVmManagerConfig().getDefaultRegion();
    }
    try {
        CloudCredentials creds = config.getVmManagerConfig().getCloudCredentials(CloudProvider.amazon);
        AWSCredentials credentials = new BasicAWSCredentials(creds.getKeyId(), creds.getKey());
        ClientConfiguration clientConfig = new ClientConfiguration();
        clientConfig.setMaxConnections(2);
        if (StringUtils.isNotBlank(creds.getProxyHost())) {
            try {
                clientConfig.setProxyHost(creds.getProxyHost());

                if (StringUtils.isNotBlank(creds.getProxyPort())) {
                    clientConfig.setProxyPort(Integer.valueOf(creds.getProxyPort()));
                }
            } catch (NumberFormatException e) {
                logger.error("invalid proxy setup.");
            }

        }
        if (StringUtils.isNotBlank(creds.getKeyId()) && StringUtils.isNotBlank(creds.getKey())) {
            asynchCloudWatchClient = new AmazonCloudWatchAsyncClient(credentials, clientConfig,
                    Executors.newFixedThreadPool(2));
            asyncSnsClient = new AmazonSNSAsyncClient(credentials, clientConfig,
                    Executors.newFixedThreadPool(2));
        } else {
            asynchCloudWatchClient = new AmazonCloudWatchAsyncClient(clientConfig);
            asyncSnsClient = new AmazonSNSAsyncClient(clientConfig);
        }
        asynchCloudWatchClient.setRegion(Region.getRegion(Regions.fromName(vmRegion.getRegion())));
        asyncSnsClient.setRegion(Region.getRegion(Regions.fromName(vmRegion.getRegion())));
    } catch (Exception ex) {
        logger.error(ex.getMessage());
        throw new RuntimeException(ex);
    }
}

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;
}

From source file:com.pearson.eidetic.driver.Common.java

public static ClientConfiguration setClientConfigurationSettings(ClientConfiguration clientConfiguration) {
    clientConfiguration.setConnectionTimeout(10000);
    clientConfiguration.setMaxConnections(10000);
    clientConfiguration.setProtocol(Protocol.HTTPS);
    clientConfiguration.setSocketTimeout(60000);

    return clientConfiguration;
}

From source file:com.sitewhere.aws.SqsOutboundEventProcessor.java

License:Open Source License

@Override
public void start() throws SiteWhereException {
    super.start();

    ClientConfiguration config = new ClientConfiguration();
    config.setMaxConnections(250);
    config.setMaxErrorRetry(5);//w w w.j a  v  a  2s  . c o  m

    if (getAccessKey() == null) {
        throw new SiteWhereException("Amazon access key not provided.");
    }

    if (getSecretKey() == null) {
        throw new SiteWhereException("Amazon secret key not provided.");
    }

    sqs = new AmazonSQSClient(new BasicAWSCredentials(getAccessKey(), getSecretKey()), config);
    Region usEast1 = Region.getRegion(Regions.US_EAST_1);
    sqs.setRegion(usEast1);
}

From source file:com.sitewhere.connectors.aws.sqs.SqsOutboundEventProcessor.java

License:Open Source License

@Override
public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException {
    super.start(monitor);

    ClientConfiguration config = new ClientConfiguration();
    config.setMaxConnections(250);
    config.setMaxErrorRetry(5);/*from w w w .ja  v a2s .  c om*/

    if (getAccessKey() == null) {
        throw new SiteWhereException("Amazon access key not provided.");
    }

    if (getSecretKey() == null) {
        throw new SiteWhereException("Amazon secret key not provided.");
    }

    sqs = new AmazonSQSClient(new BasicAWSCredentials(getAccessKey(), getSecretKey()), config);
    Region usEast1 = Region.getRegion(Regions.US_EAST_1);
    sqs.setRegion(usEast1);
}