Example usage for com.amazonaws ClientConfiguration getMaxErrorRetry

List of usage examples for com.amazonaws ClientConfiguration getMaxErrorRetry

Introduction

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

Prototype

public int getMaxErrorRetry() 

Source Link

Document

Returns the maximum number of retry attempts for failed retryable requests (ex: 5xx error responses from a service).

Usage

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  a2 s  .  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;

}