@NotThreadSafe public class ClientConfiguration extends Object
PredefinedClientConfigurations
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_CACHE_RESPONSE_METADATA
The default on whether to cache response metadata.
|
static int |
DEFAULT_CLIENT_EXECUTION_TIMEOUT
The default timeout for a request.
|
static long |
DEFAULT_CONNECTION_MAX_IDLE_MILLIS
The default maximum idle time (in milliseconds) for a connection in the connection pool.
|
static int |
DEFAULT_CONNECTION_TIMEOUT
The default timeout for creating new connections.
|
static long |
DEFAULT_CONNECTION_TTL
The default expiration time (in milliseconds) for a connection in the connection pool.
|
static int |
DEFAULT_MAX_CONNECTIONS
The default max connection pool size.
|
static int |
DEFAULT_MAX_CONSECUTIVE_RETRIES_BEFORE_THROTTLING |
static int |
DEFAULT_REQUEST_TIMEOUT
The default timeout for a request.
|
static int |
DEFAULT_RESPONSE_METADATA_CACHE_SIZE
The default response metadata cache size.
|
static RetryPolicy |
DEFAULT_RETRY_POLICY
Default request retry policy, including the maximum retry count of 3, the default retry
condition and the default back-off strategy.
|
static int |
DEFAULT_SOCKET_TIMEOUT
The default timeout for reading from a connected socket.
|
static boolean |
DEFAULT_TCP_KEEP_ALIVE
The default on whether to use TCP KeepAlive.
|
static boolean |
DEFAULT_THROTTLE_RETRIES
The default on whether to throttle retries.
|
static boolean |
DEFAULT_USE_EXPECT_CONTINUE
The default on whether to utilize the USE_EXPECT_CONTINUE handshake for operations.
|
static boolean |
DEFAULT_USE_GZIP
The default on whether to use gzip compression.
|
static boolean |
DEFAULT_USE_REAPER
The default on whether to use the
IdleConnectionReaper to manage stale connections |
static String |
DEFAULT_USER_AGENT
The default HTTP user agent header for AWS Java SDK clients.
|
static int |
DEFAULT_VALIDATE_AFTER_INACTIVITY_MILLIS
The default time a connection can be idle in the connection pool before it must be validated that it's still open.
|
Constructor and Description |
---|
ClientConfiguration() |
ClientConfiguration(ClientConfiguration other) |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(String name,
String value)
Adds a header to be added on all requests
|
ApacheHttpClientConfig |
getApacheHttpClientConfig()
Returns a non-null object that can be used to specify Apache HTTP client specific custom
configurations.
|
boolean |
getCacheResponseMetadata()
Returns whether or not to cache response metadata.
|
int |
getClientExecutionTimeout()
Returns the amount of time (in milliseconds) to allow the client to complete the execution of
an API call.
|
long |
getConnectionMaxIdleMillis()
Returns the maximum amount of time that an idle connection may sit in the connection pool and
still be eligible for reuse.
|
int |
getConnectionTimeout()
Returns the amount of time to wait (in milliseconds) when initially establishing a connection
before giving up and timing out.
|
long |
getConnectionTTL()
Returns the expiration time (in milliseconds) for a connection in the connection pool.
|
DnsResolver |
getDnsResolver()
Returns the DnsResolver for resolving AWS IP addresses.
|
Map<String,String> |
getHeaders()
Returns headers to be added to all requests
|
InetAddress |
getLocalAddress()
Returns the optional local address the client will bind to.
|
int |
getMaxConnections()
Returns the maximum number of allowed open HTTP connections.
|
int |
getMaxConsecutiveRetriesBeforeThrottling() |
int |
getMaxErrorRetry()
Returns the maximum number of retry attempts for failed retryable requests (ex: 5xx error
responses from a service).
|
String |
getNonProxyHosts()
Returns the optional hosts the client will access without going
through the proxy.
|
Protocol |
getProtocol()
Returns the protocol (HTTP or HTTPS) to use when connecting to Amazon Web Services.
|
List<ProxyAuthenticationMethod> |
getProxyAuthenticationMethods()
Returns the list of authentication methods that should be used when authenticating against an HTTP proxy, in the order they
should be attempted.
|
String |
getProxyDomain()
Returns the optional Windows domain name for configuring an NTLM proxy.
|
String |
getProxyHost()
Returns the optional proxy host the client will connect
through.
|
String |
getProxyPassword()
Returns the optional proxy password to use if connecting
through a proxy.
|
int |
getProxyPort()
Returns the optional proxy port the client will connect
through.
|
String |
getProxyUsername()
Returns the optional proxy user name to use if connecting
through a proxy.
|
String |
getProxyWorkstation()
Returns the optional Windows workstation name for configuring NTLM proxy support.
|
int |
getRequestTimeout()
Returns the amount of time to wait (in milliseconds) for the request to complete before
giving up and timing out.
|
int |
getResponseMetadataCacheSize()
Returns the response metadata cache size.
|
RetryPolicy |
getRetryPolicy()
Returns the retry policy upon failed requests.
|
SecureRandom |
getSecureRandom()
Returns the instance of
SecureRandom configured by the user; or the JDK default if it
is null. |
String |
getSignerOverride()
Returns the name of the signature algorithm to use for signing requests made by this client.
|
int[] |
getSocketBufferSizeHints()
Returns the optional size hints (in bytes) for the low level TCP send and receive buffers.
|
int |
getSocketTimeout()
Returns the amount of time to wait (in milliseconds) for data to be transfered over an
established, open connection before the connection times out and is closed.
|
String |
getUserAgent()
Deprecated.
Replaced by
getUserAgentPrefix() and getUserAgentSuffix() |
String |
getUserAgentPrefix()
Returns the HTTP user agent header prefix to send with all requests.
|
String |
getUserAgentSuffix()
Returns the HTTP user agent header suffix to add to the end of the user agent header on all requests.
|
int |
getValidateAfterInactivityMillis()
Returns the amount of time (in milliseconds) that a connection can be idle in the connection pool before it must be
validated to ensure it's still open.
|
boolean |
isPreemptiveBasicProxyAuth()
Returns whether to attempt to authenticate preemptively against proxy servers using basic
authentication
|
boolean |
isUseExpectContinue()
Returns the use expect continue flag
|
void |
setCacheResponseMetadata(boolean shouldCache)
Sets whether or not to cache response metadata.
|
void |
setClientExecutionTimeout(int clientExecutionTimeout)
Sets the amount of time (in milliseconds) to allow the client to complete the execution of
an API call.
|
void |
setConnectionMaxIdleMillis(long connectionMaxIdleMillis)
Sets the maximum amount of time that an idle connection may sit in the connection pool and
still be eligible for reuse.
|
void |
setConnectionTimeout(int connectionTimeout)
Sets the amount of time to wait (in milliseconds) when initially establishing a connection
before giving up and timing out.
|
void |
setConnectionTTL(long connectionTTL)
Sets the expiration time (in milliseconds) for a connection in the connection pool.
|
void |
setDnsResolver(DnsResolver resolver)
Sets the DNS Resolver that should be used to for resolving AWS IP addresses.
|
void |
setLocalAddress(InetAddress localAddress)
Sets the optional local address the client will bind to.
|
void |
setMaxConnections(int maxConnections)
Sets the maximum number of allowed open HTTP connections.
|
void |
setMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling)
Set the maximum number of consecutive failed retries that the client will permit before
throttling all subsequent retries of failed requests.
|
void |
setMaxErrorRetry(int maxErrorRetry)
Sets the maximum number of retry attempts for failed retryable requests (ex: 5xx error
responses from services).
|
void |
setNonProxyHosts(String nonProxyHosts)
Set the optional hosts the client will access without going
through the proxy.
|
void |
setPreemptiveBasicProxyAuth(Boolean preemptiveBasicProxyAuth)
Sets whether to attempt to authenticate preemptively against proxy servers using basic
authentication
|
void |
setProtocol(Protocol protocol)
Sets the protocol (i.e.
|
void |
setProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods)
Configure the list of authentication methods that should be used when authenticating against an HTTP proxy, in the order
they should be attempted.
|
void |
setProxyDomain(String proxyDomain)
Sets the optional Windows domain name for configuration an NTLM proxy.
|
void |
setProxyHost(String proxyHost)
Sets the optional proxy host the client will connect through.
|
void |
setProxyPassword(String proxyPassword)
Sets the optional proxy password to use when connecting through a proxy.
|
void |
setProxyPort(int proxyPort)
Sets the optional proxy port the client will connect through.
|
void |
setProxyUsername(String proxyUsername)
Sets the optional proxy user name to use if connecting through a proxy.
|
void |
setProxyWorkstation(String proxyWorkstation)
Sets the optional Windows workstation name for configuring NTLM proxy support.
|
void |
setRequestTimeout(int requestTimeout)
Sets the amount of time to wait (in milliseconds) for the request to complete before giving
up and timing out.
|
void |
setResponseMetadataCacheSize(int responseMetadataCacheSize)
Sets the response metadata cache size.
|
void |
setRetryPolicy(RetryPolicy retryPolicy)
Sets the retry policy upon failed requests.
|
void |
setSecureRandom(SecureRandom secureRandom)
Sets an instance of
SecureRandom to be used by the SDK. |
void |
setSignerOverride(String value)
Sets the name of the signature algorithm to use for signing requests made by this client.
|
void |
setSocketBufferSizeHints(int socketSendBufferSizeHint,
int socketReceiveBufferSizeHint)
Sets the optional size hints (in bytes) for the low level TCP send and receive buffers.
|
void |
setSocketTimeout(int socketTimeout)
Sets the amount of time to wait (in milliseconds) for data to be transfered over an
established, open connection before the connection times out and is closed.
|
void |
setUseExpectContinue(boolean useExpectContinue)
Sets if use expect continue should be enabled.
|
void |
setUseGzip(boolean use)
Sets whether gzip compression should be used
|
void |
setUserAgent(String userAgent)
Deprecated.
Replaced by
setUserAgentPrefix(String) and setUserAgentSuffix(String) |
void |
setUserAgentPrefix(String prefix)
Sets the HTTP user agent prefix to send with all requests.
|
void |
setUserAgentSuffix(String suffix)
Sets the HTTP user agent suffix to send with all requests.
|
void |
setUseReaper(boolean use)
Sets whether the
IdleConnectionReaper is to be started as a daemon thread |
void |
setUseTcpKeepAlive(boolean use)
Sets whether or not to enable TCP KeepAlive support at the socket level.
|
void |
setUseThrottleRetries(boolean use)
Sets whether throttled retries should be used
|
void |
setValidateAfterInactivityMillis(int validateAfterInactivityMillis)
Sets the amount of time (in milliseconds) that a connection can be idle in the connection pool before it must be validated
to ensure it's still open.
|
boolean |
useGzip()
Checks if gzip compression is used
|
boolean |
useReaper()
Checks if the
IdleConnectionReaper is to be started |
boolean |
useTcpKeepAlive()
Returns whether or not TCP KeepAlive support is enabled.
|
boolean |
useThrottledRetries()
Returns whether retry throttling will be used.
|
ClientConfiguration |
withCacheResponseMetadata(boolean shouldCache)
Sets whether or not to cache response metadata.
|
ClientConfiguration |
withClientExecutionTimeout(int clientExecutionTimeout)
Sets the amount of time (in milliseconds) to allow the client to complete the execution of
an API call.
|
ClientConfiguration |
withConnectionMaxIdleMillis(long connectionMaxIdleMillis)
Sets the maximum amount of time that an idle connection may sit in the connection pool and
still be eligible for reuse.
|
ClientConfiguration |
withConnectionTimeout(int connectionTimeout)
Sets the amount of time to wait (in milliseconds) when initially establishing a connection
before giving up and timing out, and returns the updated ClientConfiguration object so that
additional method calls may be chained together.
|
ClientConfiguration |
withConnectionTTL(long connectionTTL)
Sets the expiration time (in milliseconds) for a connection in the connection pool.
|
ClientConfiguration |
withDnsResolver(DnsResolver resolver)
Sets the DNS Resolver that should be used to for resolving AWS IP addresses.
|
ClientConfiguration |
withGzip(boolean use)
Sets whether gzip compression should be used
|
ClientConfiguration |
withHeader(String name,
String value)
Adds a header to be added on all requests and returns the
ClientConfiguration object |
ClientConfiguration |
withLocalAddress(InetAddress localAddress)
Sets the optional local address the client will bind to and returns the updated
ClientConfiguration object.
|
ClientConfiguration |
withMaxConnections(int maxConnections)
Sets the maximum number of allowed open HTTP connections and returns the updated
ClientConfiguration object.
|
ClientConfiguration |
withMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling)
Set the maximum number of consecutive failed retries that the client will permit before
throttling all subsequent retries of failed requests.
|
ClientConfiguration |
withMaxErrorRetry(int maxErrorRetry)
Sets the maximum number of retry attempts for failed retryable requests (ex: 5xx error
responses from services), and returns the updated ClientConfiguration object.
|
ClientConfiguration |
withNonProxyHosts(String nonProxyHosts)
Set the optional hosts the client will access without going
through the proxy.
|
ClientConfiguration |
withPreemptiveBasicProxyAuth(boolean preemptiveBasicProxyAuth)
Sets whether to attempt to authenticate preemptively against proxy servers using basic
authentication, and returns the updated ClientConfiguration object so that additional method
calls may be chained together.
|
ClientConfiguration |
withProtocol(Protocol protocol)
Sets the protocol (i.e.
|
ClientConfiguration |
withProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods)
Configure the list of authentication methods that should be used when authenticating against an HTTP proxy, in the order
they should be attempted.
|
ClientConfiguration |
withProxyDomain(String proxyDomain)
Sets the optional Windows domain name for configuration an NTLM proxy and returns a reference
to this updated ClientConfiguration object so that additional method calls can be chained
together.
|
ClientConfiguration |
withProxyHost(String proxyHost)
Sets the optional proxy host the client will connect through and returns the updated
ClientConfiguration object.
|
ClientConfiguration |
withProxyPassword(String proxyPassword)
Sets the optional proxy password to use when connecting through a proxy, and returns the
updated ClientConfiguration object.
|
ClientConfiguration |
withProxyPort(int proxyPort)
Sets the optional proxy port the client will connect through and returns the updated
ClientConfiguration object.
|
ClientConfiguration |
withProxyUsername(String proxyUsername)
Sets the optional proxy user name and returns the updated ClientConfiguration object.
|
ClientConfiguration |
withProxyWorkstation(String proxyWorkstation)
Sets the optional Windows workstation name for configuring NTLM proxy support, and returns
the updated ClientConfiguration object so that additional method calls can be chained
together.
|
ClientConfiguration |
withReaper(boolean use)
Sets whether the
IdleConnectionReaper is to be started as a daemon thread |
ClientConfiguration |
withRequestTimeout(int requestTimeout)
Sets the amount of time to wait (in milliseconds) for the request to complete before giving
up and timing out.
|
ClientConfiguration |
withResponseMetadataCacheSize(int responseMetadataCacheSize)
Sets the response metadata cache size.
|
ClientConfiguration |
withRetryPolicy(RetryPolicy retryPolicy)
Sets the retry policy upon failed requests, and returns the updated ClientConfiguration
object.
|
ClientConfiguration |
withSecureRandom(SecureRandom secureRandom)
Fluent API for
setSecureRandom(SecureRandom) . |
ClientConfiguration |
withSignerOverride(String value)
Sets the name of the signature algorithm to use for signing requests made by this client.
|
ClientConfiguration |
withSocketBufferSizeHints(int socketSendBufferSizeHint,
int socketReceiveBufferSizeHint)
Sets the optional size hints (in bytes) for the low level TCP send and receive buffers, and
returns the updated ClientConfiguration object so that additional method calls may be chained
together.
|
ClientConfiguration |
withSocketTimeout(int socketTimeout)
Sets the amount of time to wait (in milliseconds) for data to be transfered over an
established, open connection before the connection times out and is closed, and returns the
updated ClientConfiguration object so that additional method calls may be chained together.
|
ClientConfiguration |
withTcpKeepAlive(boolean use)
Sets whether or not to enable TCP KeepAlive support at the socket level.
|
ClientConfiguration |
withThrottledRetries(boolean use)
Sets whether throttled retries should be used
|
ClientConfiguration |
withUseExpectContinue(boolean useExpectContinue)
Sets if use expect continue should be enabled.
|
ClientConfiguration |
withUserAgent(String userAgent)
Deprecated.
Replaced by
withUserAgentPrefix(String) and withUserAgentSuffix(String) |
ClientConfiguration |
withUserAgentPrefix(String prefix)
Sets the HTTP user agent prefix header used in requests and returns the updated ClientConfiguration
object.
|
ClientConfiguration |
withUserAgentSuffix(String suffix)
Sets the HTTP user agent suffix header used in requests and returns the updated ClientConfiguration
object.
|
ClientConfiguration |
withValidateAfterInactivityMillis(int validateAfterInactivityMillis)
Sets the amount of time (in milliseconds) that a connection can be idle in the connection pool before it must be validated
to ensure it's still open.
|
public static final int DEFAULT_CONNECTION_TIMEOUT
public static final int DEFAULT_SOCKET_TIMEOUT
public static final int DEFAULT_REQUEST_TIMEOUT
public static final int DEFAULT_CLIENT_EXECUTION_TIMEOUT
public static final int DEFAULT_MAX_CONNECTIONS
public static final boolean DEFAULT_USE_EXPECT_CONTINUE
public static final String DEFAULT_USER_AGENT
public static final RetryPolicy DEFAULT_RETRY_POLICY
public static final boolean DEFAULT_USE_REAPER
IdleConnectionReaper
to manage stale connectionsIdleConnectionReaper
,
Constant Field Valuespublic static final boolean DEFAULT_USE_GZIP
public static final long DEFAULT_CONNECTION_TTL
public static final long DEFAULT_CONNECTION_MAX_IDLE_MILLIS
public static final int DEFAULT_VALIDATE_AFTER_INACTIVITY_MILLIS
public static final boolean DEFAULT_TCP_KEEP_ALIVE
public static final boolean DEFAULT_THROTTLE_RETRIES
public static final boolean DEFAULT_CACHE_RESPONSE_METADATA
public static final int DEFAULT_RESPONSE_METADATA_CACHE_SIZE
public static final int DEFAULT_MAX_CONSECUTIVE_RETRIES_BEFORE_THROTTLING
public ClientConfiguration()
public ClientConfiguration(ClientConfiguration other)
public Protocol getProtocol()
The default configuration is to use HTTPS for all requests for increased security.
Individual clients can also override this setting by explicitly including the protocol as
part of the endpoint URL when calling AmazonWebServiceClient.setEndpoint(String)
.
public void setProtocol(Protocol protocol)
The default configuration is to use HTTPS for all requests for increased security.
Individual clients can also override this setting by explicitly including the protocol as
part of the endpoint URL when calling AmazonWebServiceClient.setEndpoint(String)
.
protocol
- The protocol to use when connecting to Amazon Web Services.public ClientConfiguration withProtocol(Protocol protocol)
The default configuration is to use HTTPS for all requests for increased security.
Individual clients can also override this setting by explicitly including the protocol as
part of the endpoint URL when calling AmazonWebServiceClient.setEndpoint(String)
.
protocol
- The protocol to use when connecting to Amazon Web Services.public int getMaxConnections()
public void setMaxConnections(int maxConnections)
maxConnections
- The maximum number of allowed open HTTP connections.public ClientConfiguration withMaxConnections(int maxConnections)
maxConnections
- The maximum number of allowed open HTTP connections.@Deprecated public String getUserAgent()
getUserAgentPrefix()
and getUserAgentSuffix()
@Deprecated public void setUserAgent(String userAgent)
setUserAgentPrefix(String)
and setUserAgentSuffix(String)
userAgent
- The user agent string to use when sending requests.@Deprecated public ClientConfiguration withUserAgent(String userAgent)
withUserAgentPrefix(String)
and withUserAgentSuffix(String)
userAgent
- The user agent string to use when sending requests.public String getUserAgentPrefix()
public void setUserAgentPrefix(String prefix)
prefix
- The string to prefix to user agent to use when sending requests.public ClientConfiguration withUserAgentPrefix(String prefix)
prefix
- The string to prefix to user agent to use when sending requests.public String getUserAgentSuffix()
public void setUserAgentSuffix(String suffix)
suffix
- The string to suffix to user agent to use when sending requests.public ClientConfiguration withUserAgentSuffix(String suffix)
suffix
- The string to suffix to user agent to use when sending requests.public InetAddress getLocalAddress()
public void setLocalAddress(InetAddress localAddress)
localAddress
- The local address the client will bind to.public ClientConfiguration withLocalAddress(InetAddress localAddress)
localAddress
- The local address the client will bind to.public String getProxyHost()
getProtocol()
: i.e. if
protocol is https, returns the value of the system property
https.proxyHost, otherwise returns value of http.proxyHost.public void setProxyHost(String proxyHost)
proxyHost
- The proxy host the client will connect through.public ClientConfiguration withProxyHost(String proxyHost)
proxyHost
- The proxy host the client will connect through.public int getProxyPort()
getProtocol()
: i.e. if
protocol is https, returns the value of the system property
https.proxyPort, otherwise returns value of http.proxyPort.public void setProxyPort(int proxyPort)
proxyPort
- The proxy port the client will connect through.public ClientConfiguration withProxyPort(int proxyPort)
proxyPort
- The proxy port the client will connect through.public String getProxyUsername()
getProtocol()
:
i.e. if protocol is https, returns the value of the system
property https.proxyUser, otherwise returns value of
http.proxyUser.public void setProxyUsername(String proxyUsername)
proxyUsername
- The proxy user name to use if connecting through a proxy.public ClientConfiguration withProxyUsername(String proxyUsername)
proxyUsername
- The proxy user name to use if connecting through a proxy.public String getProxyPassword()
getProtocol()
:
i.e. if protocol is https, returns the value of the system
property https.proxyPassword, otherwise returns value of
http.proxyPassword.public void setProxyPassword(String proxyPassword)
proxyPassword
- The password to use when connecting through a proxy.public ClientConfiguration withProxyPassword(String proxyPassword)
proxyPassword
- The password to use when connecting through a proxy.public String getProxyDomain()
public void setProxyDomain(String proxyDomain)
proxyDomain
- The optional Windows domain name for configuring an NTLM proxy.public ClientConfiguration withProxyDomain(String proxyDomain)
proxyDomain
- The optional Windows domain name for configuring an NTLM proxy.public String getProxyWorkstation()
public void setProxyWorkstation(String proxyWorkstation)
proxyWorkstation
- The optional Windows workstation name for configuring NTLM proxy support.public ClientConfiguration withProxyWorkstation(String proxyWorkstation)
proxyWorkstation
- The optional Windows workstation name for configuring NTLM proxy support.public String getNonProxyHosts()
getProtocol()
: i.e. if
protocol is https, returns null, otherwise returns value of http.nonProxyHosts.public void setNonProxyHosts(String nonProxyHosts)
nonProxyHosts
- The hosts the client will access without going through the proxy.public ClientConfiguration withNonProxyHosts(String nonProxyHosts)
nonProxyHosts
- The hosts the client will access without going through the proxy.public List<ProxyAuthenticationMethod> getProxyAuthenticationMethods()
public void setProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods)
Setting this value to null indicates using the default behavior, which is to try all authentication methods in an unspecified order.
proxyAuthenticationMethods
- The proxy authentication methods to be attempted, in the order they should be attempted.public ClientConfiguration withProxyAuthenticationMethods(List<ProxyAuthenticationMethod> proxyAuthenticationMethods)
Setting this value to null indicates using the default behavior, which is to try all authentication methods in an unspecified order.
proxyAuthenticationMethods
- The proxy authentication methods to be attempted, in the order they should be attempted.public RetryPolicy getRetryPolicy()
public void setRetryPolicy(RetryPolicy retryPolicy)
setMaxErrorRetry(int)
.retryPolicy
- The retry policy upon failed requests.public ClientConfiguration withRetryPolicy(RetryPolicy retryPolicy)
setMaxErrorRetry(int)
retryPolicy
- The retry policy upon failed requests.public int getMaxErrorRetry()
setMaxErrorRetry(int)
, in which case the configured RetryPolicy will be used
to control the retry count.setMaxErrorRetry(int)
.public void setMaxErrorRetry(int maxErrorRetry)
maxErrorRetry
- The maximum number of retry attempts for failed retryable requests. This value
should not be negative.public ClientConfiguration withMaxErrorRetry(int maxErrorRetry)
maxErrorRetry
- The maximum number of retry attempts for failed retryable requests. This value
should not be negative.public int getSocketTimeout()
public void setSocketTimeout(int socketTimeout)
socketTimeout
- The amount of time to wait (in milliseconds) for data to be transfered over an
established, open connection before the connection times out and is closed.public ClientConfiguration withSocketTimeout(int socketTimeout)
socketTimeout
- The amount of time to wait (in milliseconds) for data to be transfered over an
established, open connection before the connection times out and is closed.public int getConnectionTimeout()
public void setConnectionTimeout(int connectionTimeout)
connectionTimeout
- The amount of time to wait (in milliseconds) when initially establishing a
connection before giving up and timing out.public ClientConfiguration withConnectionTimeout(int connectionTimeout)
connectionTimeout
- the amount of time to wait (in milliseconds) when initially establishing a
connection before giving up and timing out.public int getRequestTimeout()
This feature requires buffering the entire response (for non-streaming APIs) into memory to enforce a hard timeout when reading the response. For APIs that return large responses this could be expensive.
The request timeout feature doesn't have strict guarantees on how quickly a request is aborted when the timeout is breached. The typical case aborts the request within a few milliseconds but there may occasionally be requests that don't get aborted until several seconds after the timer has been breached. Because of this, the request timeout feature should not be used when absolute precision is needed.
Note: This feature is not compatible with Java 1.6.ClientConfiguration#setClientExecutionTimeout(int)} to enforce a timeout across
all retries
public void setRequestTimeout(int requestTimeout)
This feature requires buffering the entire response (for non-streaming APIs) into memory to enforce a hard timeout when reading the response. For APIs that return large responses this could be expensive.
The request timeout feature doesn't have strict guarantees on how quickly a request is aborted when the timeout is breached. The typical case aborts the request within a few milliseconds but there may occasionally be requests that don't get aborted until several seconds after the timer has been breached. Because of this, the request timeout feature should not be used when absolute precision is needed.
Note: This feature is not compatible with Java 1.6.
requestTimeout
- The amount of time to wait (in milliseconds) for the request to complete before
giving up and timing out.ClientConfiguration#setClientExecutionTimeout(int)} to enforce a timeout across
all retries
public ClientConfiguration withRequestTimeout(int requestTimeout)
This feature requires buffering the entire response (for non-streaming APIs) into memory to enforce a hard timeout when reading the response. For APIs that return large responses this could be expensive.
The request timeout feature doesn't have strict guarantees on how quickly a request is aborted when the timeout is breached. The typical case aborts the request within a few milliseconds but there may occasionally be requests that don't get aborted until several seconds after the timer has been breached. Because of this, the request timeout feature should not be used when absolute precision is needed.
Note: This feature is not compatible with Java 1.6.
requestTimeout
- The amount of time to wait (in milliseconds) for the request to complete before
giving up and timing out.ClientConfiguration#setClientExecutionTimeout(int)} to enforce a timeout across
all retries
public int getClientExecutionTimeout()
This feature requires buffering the entire response (for non-streaming APIs) into memory to enforce a hard timeout when reading the response. For APIs that return large responses this could be expensive.
The client execution timeout feature doesn't have strict guarantees on how quickly a request is aborted when the timeout is breached. The typical case aborts the request within a few milliseconds but there may occasionally be requests that don't get aborted until several seconds after the timer has been breached. Because of this, the client execution timeout feature should not be used when absolute precision is needed.
This may be used together with setRequestTimeout(int)
to enforce
both a timeout on each individual HTTP request (i.e. each retry) and the total time spent on
all requests across retries (i.e. the 'client execution' time). A non-positive value disables
this feature.
Note: This feature is not compatible with Java 1.6.
ClientConfiguration#setRequestTimeout(int)} to enforce a timeout per HTTP request
public void setClientExecutionTimeout(int clientExecutionTimeout)
This feature requires buffering the entire response (for non-streaming APIs) into memory to enforce a hard timeout when reading the response. For APIs that return large responses this could be expensive.
The client execution timeout feature doesn't have strict guarantees on how quickly a request is aborted when the timeout is breached. The typical case aborts the request within a few milliseconds but there may occasionally be requests that don't get aborted until several seconds after the timer has been breached. Because of this, the client execution timeout feature should not be used when absolute precision is needed.
This may be used together with setRequestTimeout(int)
to enforce
both a timeout on each individual HTTP request (i.e. each retry) and the total time spent on
all requests across retries (i.e. the 'client execution' time). A non-positive value disables
this feature.
Note: This feature is not compatible with Java 1.6.
clientExecutionTimeout
- The amount of time (in milliseconds) to allow the client to complete the execution
of an API call. A value of '0' disables this feature.ClientConfiguration#setRequestTimeout(int)} to enforce a timeout per HTTP request
public ClientConfiguration withClientExecutionTimeout(int clientExecutionTimeout)
This feature requires buffering the entire response (for non-streaming APIs) into memory to enforce a hard timeout when reading the response. For APIs that return large responses this could be expensive.
The client execution timeout feature doesn't have strict guarantees on how quickly a request is aborted when the timeout is breached. The typical case aborts the request within a few milliseconds but there may occasionally be requests that don't get aborted until several seconds after the timer has been breached. Because of this, the client execution timeout feature should not be used when absolute precision is needed.
This may be used together with setRequestTimeout(int)
to enforce
both a timeout on each individual HTTP request (i.e. each retry) and the total time spent on
all requests across retries (i.e. the 'client execution' time). A non-positive value disables
this feature.
Note: This feature is not compatible with Java 1.6.
clientExecutionTimeout
- The amount of time (in milliseconds) to allow the client to complete the execution
of an API call. A value of '0' disables this feature.ClientConfiguration#setRequestTimeout(int)} to enforce a timeout per HTTP request
public boolean useReaper()
IdleConnectionReaper
is to be startedIdleConnectionReaper
is to be startedpublic void setUseReaper(boolean use)
IdleConnectionReaper
is to be started as a daemon threaduse
- whether the IdleConnectionReaper
is to be started as a daemon threadIdleConnectionReaper
public ClientConfiguration withReaper(boolean use)
IdleConnectionReaper
is to be started as a daemon threaduse
- the IdleConnectionReaper
is to be started as a daemon threadpublic boolean useThrottledRetries()
Retry throttling is a feature which intelligently throttles retry attempts when a large percentage of requests are failing and retries are unsuccessful, particularly in scenarios of degraded service health. In these situations the client will drain its internal retry capacity and slowly roll off from retry attempts until requests begin to succeed again. At that point the retry capacity pool will begin to refill and retries will once again be permitted.
In situations where retries have been throttled this feature will effectively result in fail-fast behavior from the client. Because retries are circumvented exceptions will be immediately returned to the caller if the initial request is unsuccessful. This will result in a greater number of exceptions being returned up front but prevents requests being tied up attempting subsequent retries which are also likely to fail.
public void setUseThrottleRetries(boolean use)
Retry throttling is a feature which intelligently throttles retry attempts when a large percentage of requests are failing and retries are unsuccessful, particularly in scenarios of degraded service health. In these situations the client will drain its internal retry capacity and slowly roll off from retry attempts until requests begin to succeed again. At that point the retry capacity pool will begin to refill and retries will once again be permitted.
In situations where retries have been throttled this feature will effectively result in fail-fast behavior from the client. Because retries are circumvented exceptions will be immediately returned to the caller if the initial request is unsuccessful. This will result in a greater number of exceptions being returned up front but prevents requests being tied up attempting subsequent retries which are also likely to fail.
use
- true if throttled retries should be usedpublic ClientConfiguration withThrottledRetries(boolean use)
Retry throttling is a feature which intelligently throttles retry attempts when a large percentage of requests are failing and retries are unsuccessful, particularly in scenarios of degraded service health. In these situations the client will drain its internal retry capacity and slowly roll off from retry attempts until requests begin to succeed again. At that point the retry capacity pool will begin to refill and retries will once again be permitted.
In situations where retries have been throttled this feature will effectively result in fail-fast behavior from the client. Because retries are circumvented exceptions will be immediately returned to the caller if the initial request is unsuccessful. This will result in a greater number of exceptions being returned up front but prevents requests being tied up attempting subsequent retries which are also likely to fail.
use
- true if throttled retries should be usedpublic void setMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling)
Note: This does not guarantee that each failed request will be retried up to this many times.
Depending on the configured RetryPolicy
and the number of past failed and successful
requests, the actual number of retries attempted may be less.
This has a default value of DEFAULT_MAX_CONSECUTIVE_RETRIES_BEFORE_THROTTLING
.
maxConsecutiveRetriesBeforeThrottling
- The maximum number of consecutive retries.public ClientConfiguration withMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling)
Note: This does not guarantee that each failed request will be retried up to this many times.
Depending on the configured RetryPolicy
and the number of past failed and successful
requests, the actual number of retries attempted may be less.
This has a default value of DEFAULT_MAX_CONSECUTIVE_RETRIES_BEFORE_THROTTLING
.
maxConsecutiveRetriesBeforeThrottling
- The maximum number of consecutive retries.public int getMaxConsecutiveRetriesBeforeThrottling()
public boolean useGzip()
public void setUseGzip(boolean use)
use
- whether gzip compression should be usedpublic ClientConfiguration withGzip(boolean use)
use
- whether gzip compression should be usedpublic int[] getSocketBufferSizeHints()
The optimal TCP buffer sizes for a particular application are highly dependent on network configuration and operating system configuration and capabilities. For example, most modern operating systems provide auto-tuning functionality for TCP buffer sizes, which can have a big impact on performance for TCP connections that are held open long enough for the auto-tuning to optimize buffer sizes.
Large buffer sizes (ex: 2MB) will allow the operating system to buffer more data in memory without requiring the remote server to acknowledge receipt of that information, so can be particularly useful when the network has high latency.
This is only a hint, and the operating system may choose not to honor it. When using this option, users should always check the operating system's configured limits and defaults. Most OS's have a maximum TCP buffer size limit configured, and won't let you go beyond that limit unless you explicitly raise the max TCP buffer size limit.
There are many resources available online to help with configuring TCP buffer sizes and operating system specific TCP settings, including:
public void setSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint)
The optimal TCP buffer sizes for a particular application are highly dependent on network configuration and operating system configuration and capabilities. For example, most modern operating systems provide auto-tuning functionality for TCP buffer sizes, which can have a big impact on performance for TCP connections that are held open long enough for the auto-tuning to optimize buffer sizes.
Large buffer sizes (ex: 2MB) will allow the operating system to buffer more data in memory without requiring the remote server to acknowledge receipt of that information, so can be particularly useful when the network has high latency.
This is only a hint, and the operating system may choose not to honor it. When using this option, users should always check the operating system's configured limits and defaults. Most OS's have a maximum TCP buffer size limit configured, and won't let you go beyond that limit unless you explicitly raise the max TCP buffer size limit.
There are many resources available online to help with configuring TCP buffer sizes and operating system specific TCP settings, including:
socketSendBufferSizeHint
- The size hint (in bytes) for the low level TCP send buffer.socketReceiveBufferSizeHint
- The size hint (in bytes) for the low level TCP receive buffer.public ClientConfiguration withSocketBufferSizeHints(int socketSendBufferSizeHint, int socketReceiveBufferSizeHint)
This is an advanced option for advanced users who want to tune low level TCP parameters to try and squeeze out more performance.
The optimal TCP buffer sizes for a particular application are highly dependent on network configuration and operating system configuration and capabilities. For example, most modern operating systems provide auto-tuning functionality for TCP buffer sizes, which can have a big impact on performance for TCP connections that are held open long enough for the auto-tuning to optimize buffer sizes.
Large buffer sizes (ex: 2MB) will allow the operating system to buffer more data in memory without requiring the remote server to acknowledge receipt of that information, so can be particularly useful when the network has high latency.
This is only a hint, and the operating system may choose not to honor it. When using this option, users should always check the operating system's configured limits and defaults. Most OS's have a maximum TCP buffer size limit configured, and won't let you go beyond that limit unless you explicitly raise the max TCP buffer size limit.
There are many resources available online to help with configuring TCP buffer sizes and operating system specific TCP settings, including:
socketSendBufferSizeHint
- The size hint (in bytes) for the low level TCP send buffer.socketReceiveBufferSizeHint
- The size hint (in bytes) for the low level TCP receive buffer.public String getSignerOverride()
Most users do not need to concern themselves with which signature algorithm is being used, as the defaults will be sufficient. This setting exists only so advanced users can opt in to newer signature protocols which have not yet been made the default for a particular service/region.
Not all services support all signature algorithms, and configuring an unsupported signature algorithm will lead to authentication failures. Use me at your own risk, and only after consulting the documentation for the service to ensure it actually does supports your chosen algorithm.
If non-null, the name returned from this method is used to look up a Signer
class
implementing the chosen algorithm by the com.amazonaws.auth.SignerFactory
class.
public void setSignerOverride(String value)
Most users do not need to concern themselves with which signature algorithm is being used, as the defaults will be sufficient. This setting exists only so advanced users can opt in to newer signature protocols which have not yet been made the default for a particular service/region.
Not all services support all signature algorithms, and configuring an unsupported signature algorithm will lead to authentication failures. Use me at your own risk, and only after consulting the documentation for the service to ensure it actually does supports your chosen algorithm.
If non-null, the name returned from this method is used to look up a Signer
class
implementing the chosen algorithm by the com.amazonaws.auth.SignerFactory
class.
value
- The signature algorithm to use for this client, or null to use the default.public ClientConfiguration withSignerOverride(String value)
Most users do not need to concern themselves with which signature algorithm is being used, as the defaults will be sufficient. This setting exists only so advanced users can opt in to newer signature protocols which have not yet been made the default for a particular service/region.
Not all services support all signature algorithms, and configuring an unsupported signature algorithm will lead to authentication failures. Use me at your own risk, and only after consulting the documentation for the service to ensure it actually does supports your chosen algorithm.
If non-null, the name returned from this method is used to look up a Signer
class
implementing the chosen algorithm by the com.amazonaws.auth.SignerFactory
class.
value
- The signature algorithm to use for this client, or null to use the default.public boolean isPreemptiveBasicProxyAuth()
public void setPreemptiveBasicProxyAuth(Boolean preemptiveBasicProxyAuth)
preemptiveBasicProxyAuth
- Whether to authenticate preemptively against proxy server.public ClientConfiguration withPreemptiveBasicProxyAuth(boolean preemptiveBasicProxyAuth)
preemptiveBasicProxyAuth
- Whether to authenticate preemptively against proxy server.public long getConnectionTTL()
Tuning this setting down (together with an appropriately-low setting for Java's DNS cache TTL) ensures that your application will quickly rotate over to new IP addresses when the service begins announcing them through DNS, at the cost of having to re-establish new connections more frequently.
public void setConnectionTTL(long connectionTTL)
Tuning this setting down (together with an appropriately-low setting for Java's DNS cache TTL) ensures that your application will quickly rotate over to new IP addresses when the service begins announcing them through DNS, at the cost of having to re-establish new connections more frequently.
By default, it is set to {@code -1], i.e. connections do not expire.
connectionTTL
- the connection TTL, in millisecondspublic ClientConfiguration withConnectionTTL(long connectionTTL)
Tuning this setting down (together with an appropriately-low setting for Java's DNS cache TTL) ensures that your application will quickly rotate over to new IP addresses when the service begins announcing them through DNS, at the cost of having to re-establish new connections more frequently.
By default, it is set to -1
, i.e. connections do not expire.
connectionTTL
- the connection TTL, in millisecondspublic long getConnectionMaxIdleMillis()
Tuning this setting down reduces the likelihood of a race condition (wherein you begin sending a request down a connection which appears to be healthy, but before it arrives the service decides the connection has been idle for too long and closes it) at the cost of having to re-establish new connections more frequently.
public void setConnectionMaxIdleMillis(long connectionMaxIdleMillis)
Tuning this setting down reduces the likelihood of a race condition (wherein you begin sending a request down a connection which appears to be healthy, but before it arrives the service decides the connection has been idle for too long and closes it) at the cost of having to re-establish new connections more frequently.
By default, it is set to one minute (60000ms).
connectionMaxIdleMillis
- the connection maximum idle time, in millisecondspublic ClientConfiguration withConnectionMaxIdleMillis(long connectionMaxIdleMillis)
Tuning this setting down reduces the likelihood of a race condition (wherein you begin sending a request down a connection which appears to be healthy, but before it arrives the service decides the connection has been idle for too long and closes it) at the cost of having to re-establish new connections more frequently.
By default, it is set to one minute (60000ms).
connectionMaxIdleMillis
- the connection maximum idle time, in millisecondspublic int getValidateAfterInactivityMillis()
NoHttpResponseException
. Lowering this setting increases the overhead when leasing
connections from the connection pool. It is recommended to tune this setting based on how long a service allows a
connection to be idle before closing.
A non positive value disables validation of connections.
The default value is 5000 milliseconds.
public void setValidateAfterInactivityMillis(int validateAfterInactivityMillis)
NoHttpResponseException
. Lowering this setting increases the overhead when leasing connections
from the connection pool. It is recommended to tune this setting based on how long a service allows a connection to be
idle before closing.
A non positive value disables validation of connections.
The default value is 5000 milliseconds.
validateAfterInactivityMillis
- The allowed time, in milliseconds, a connection can be idle before it must be
re-validated.public ClientConfiguration withValidateAfterInactivityMillis(int validateAfterInactivityMillis)
NoHttpResponseException
. Lowering this setting increases the overhead when leasing connections
from the connection pool. It is recommended to tune this setting based on how long a service allows a connection to be
idle before closing.
A non positive value disables validation of connections.
The default value is 5000 milliseconds.
validateAfterInactivityMillis
- The allowed time, in milliseconds, a connection can be idle before it must be
re-validated.ClientConfiguration
object.public boolean useTcpKeepAlive()
public void setUseTcpKeepAlive(boolean use)
public ClientConfiguration withTcpKeepAlive(boolean use)
public DnsResolver getDnsResolver()
SystemDefaultDnsResolver
by default if not
explicitly configured by the user.public void setDnsResolver(DnsResolver resolver)
public ClientConfiguration withDnsResolver(DnsResolver resolver)
public boolean getCacheResponseMetadata()
Response metadata is typically used for troubleshooting issues with AWS support staff when services aren't acting as expected.
While this feature is useful for debugging it adds overhead and disabling it may be desired in high throughput applications.
public void setCacheResponseMetadata(boolean shouldCache)
Response metadata is typically used for troubleshooting issues with AWS support staff when services aren't acting as expected.
While this feature is useful for debugging it adds overhead and disabling it may be desired in high throughput applications.
shouldCache
- true if response metadata should be cachedpublic ClientConfiguration withCacheResponseMetadata(boolean shouldCache)
Response metadata is typically used for troubleshooting issues with AWS support staff when services aren't acting as expected.
While this feature is useful for debugging it adds overhead and disabling it may be desired in high throughput applications.
shouldCache
- true if response metadata should be cachedpublic int getResponseMetadataCacheSize()
public void setResponseMetadataCacheSize(int responseMetadataCacheSize)
responseMetadataCacheSize
- maximum cache size.public ClientConfiguration withResponseMetadataCacheSize(int responseMetadataCacheSize)
responseMetadataCacheSize
- maximum cache size.public ApacheHttpClientConfig getApacheHttpClientConfig()
public SecureRandom getSecureRandom()
SecureRandom
configured by the user; or the JDK default if it
is null.public void setSecureRandom(SecureRandom secureRandom)
SecureRandom
to be used by the SDK.public ClientConfiguration withSecureRandom(SecureRandom secureRandom)
setSecureRandom(SecureRandom)
.public boolean isUseExpectContinue()
public void setUseExpectContinue(boolean useExpectContinue)
useExpectContinue
- use expect continue HTTP/1.1 header.public ClientConfiguration withUseExpectContinue(boolean useExpectContinue)
useExpectContinue
- use expect continue HTTP/1.1 header.public ClientConfiguration withHeader(String name, String value)
ClientConfiguration
objectname
- the name of the headervalue
- the value of the headerpublic void addHeader(String name, String value)
name
- the name of the headervalue
- the value of the headerCopyright © 2013 Amazon Web Services, Inc. All Rights Reserved.