public class ClientConfiguration
extends java.lang.Object
PredefinedClientConfigurations
Modifier and Type | Field and Description |
---|---|
private ApacheHttpClientConfig |
apacheHttpClientConfig
Can be used to specify custom specific Apache HTTP client configurations.
|
private int |
clientExecutionTimeout |
private long |
connectionMaxIdleMillis
The maximum idle time for a connection in the connection pool.
|
private int |
connectionTimeout
The amount of time to wait (in milliseconds) when initially establishing a connection before
giving up and timing out.
|
private long |
connectionTTL
Optional expiration time for a connection in the connection pool.
|
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_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.
|
private 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 java.lang.String |
DEFAULT_USER_AGENT
The default HTTP user agent header for AWS Java SDK clients.
|
private DnsResolver |
dnsResolver
The DNS Resolver to resolve IP addresses of Amazon Web Services.
|
private java.net.InetAddress |
localAddress
Optionally specifies the local address to bind to
|
private int |
maxConnections
The maximum number of open HTTP connections.
|
private int |
maxErrorRetry
The maximum number of times that a retryable failed request (ex: a 5xx response from a
service) will be retried.
|
private boolean |
preemptiveBasicProxyAuth
Whether to pre-emptively authenticate against a proxy server using basic authentication
|
private Protocol |
protocol
The protocol to use when connecting to Amazon Web Services.
|
private java.lang.String |
proxyDomain
Optional Windows domain name for configuring NTLM proxy support.
|
private java.lang.String |
proxyHost
Optionally specifies the proxy host to connect through.
|
private java.lang.String |
proxyPassword
Optionally specifies the password to use when connecting through a proxy.
|
private int |
proxyPort
Optionally specifies the port on the proxy host to connect through.
|
private java.lang.String |
proxyUsername
Optionally specifies the user name to use when connecting through a proxy.
|
private java.lang.String |
proxyWorkstation
Optional Windows workstation name for configuring NTLM proxy support.
|
private int |
requestTimeout
The amount of time to wait (in milliseconds) for a request to complete before giving up and
timing out.
|
private int |
responseMetadataCacheSize
Size of the response metadata cache.
|
private RetryPolicy |
retryPolicy
The retry policy upon failed requests.
|
private java.security.SecureRandom |
secureRandom
An instance of
SecureRandom configured by the user; or the JDK default will be used
if it is set to null or not explicitly configured. |
private java.lang.String |
signerOverride
Optional override to control which signature algorithm should be used to sign requests to the
service.
|
private int |
socketReceiveBufferSizeHint
Optional size hint (in bytes) for the low level TCP receive buffer.
|
private int |
socketSendBufferSizeHint
Optional size hint (in bytes) for the low level TCP send buffer.
|
private int |
socketTimeout
The amount of time to wait (in milliseconds) for data to be transfered over an established,
open connection before the connection is timed out.
|
private boolean |
tcpKeepAlive
Optional override to enable support for TCP KeepAlive (not to be confused with HTTP
KeepAlive).
|
private boolean |
throttleRetries |
private boolean |
useExpectContinue
Optional override to enable/disable support for HTTP/1.1 handshake utilizing EXPECT:
100-Continue.
|
private boolean |
useGzip
Optional whether to use gzip compression when making HTTP requests.
|
private java.lang.String |
userAgent
The HTTP user agent header passed with all HTTP requests.
|
private boolean |
useReaper
Optional whether to use the
IdleConnectionReaper to manage stale connections. |
Constructor and Description |
---|
ClientConfiguration() |
ClientConfiguration(ClientConfiguration other) |
Modifier and Type | Method and Description |
---|---|
ApacheHttpClientConfig |
getApacheHttpClientConfig()
Returns a non-null object that can be used to specify Apache HTTP client specific custom
configurations.
|
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.
|
java.net.InetAddress |
getLocalAddress()
Returns the optional local address the client will bind to.
|
int |
getMaxConnections()
Returns the maximum number of allowed open HTTP connections.
|
int |
getMaxErrorRetry()
Returns the maximum number of retry attempts for failed retryable requests (ex: 5xx error
responses from a service).
|
Protocol |
getProtocol()
Returns the protocol (HTTP or HTTPS) to use when connecting to Amazon Web Services.
|
java.lang.String |
getProxyDomain()
Returns the optional Windows domain name for configuring an NTLM proxy.
|
java.lang.String |
getProxyHost()
Returns the optional proxy host the client will connect
through.
|
private java.lang.String |
getProxyHostProperty()
Returns the Java system property for proxy host depending on
this.getProtocol() : i.e. |
java.lang.String |
getProxyPassword()
Returns the optional proxy password to use if connecting
through a proxy.
|
private java.lang.String |
getProxyPasswordProperty()
Returns the Java system property for proxy password depending on
this.getProtocol() : i.e. |
int |
getProxyPort()
Returns the optional proxy port the client will connect
through.
|
private int |
getProxyPortProperty()
Returns the Java system property for proxy port depending on
this.getProtocol() : i.e. |
java.lang.String |
getProxyUsername()
Returns the optional proxy user name to use if connecting
through a proxy.
|
private java.lang.String |
getProxyUsernameProperty()
Returns the Java system property for proxy user name depending on
this.getProtocol() : i.e. |
java.lang.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.
|
java.security.SecureRandom |
getSecureRandom()
Returns the instance of
SecureRandom configured by the user; or the JDK default if it
is null. |
java.lang.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.
|
private java.lang.String |
getSystemProperty(java.lang.String property)
Returns the value for the given system property.
|
java.lang.String |
getUserAgent()
Returns the HTTP user agent header to send with all requests.
|
boolean |
isPreemptiveBasicProxyAuth()
Returns whether to attempt to authenticate preemptively against proxy servers using basic
authentication
|
boolean |
isUseExpectContinue()
Returns the use expect continue flag
|
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(java.net.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 |
setMaxErrorRetry(int maxErrorRetry)
Sets the maximum number of retry attempts for failed retryable requests (ex: 5xx error
responses from services).
|
void |
setPreemptiveBasicProxyAuth(java.lang.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 |
setProxyDomain(java.lang.String proxyDomain)
Sets the optional Windows domain name for configuration an NTLM proxy.
|
void |
setProxyHost(java.lang.String proxyHost)
Sets the optional proxy host the client will connect through.
|
void |
setProxyPassword(java.lang.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(java.lang.String proxyUsername)
Sets the optional proxy user name to use if connecting through a proxy.
|
void |
setProxyWorkstation(java.lang.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(java.security.SecureRandom secureRandom)
Sets an instance of
SecureRandom to be used by the SDK. |
void |
setSignerOverride(java.lang.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(java.lang.String userAgent)
Sets the HTTP user agent header 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
|
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 |
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 |
withLocalAddress(java.net.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 |
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 |
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 |
withProxyDomain(java.lang.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(java.lang.String proxyHost)
Sets the optional proxy host the client will connect through and returns the updated
ClientConfiguration object.
|
ClientConfiguration |
withProxyPassword(java.lang.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(java.lang.String proxyUsername)
Sets the optional proxy user name and returns the updated ClientConfiguration object.
|
ClientConfiguration |
withProxyWorkstation(java.lang.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(java.security.SecureRandom secureRandom)
Fluent API for
setSecureRandom(SecureRandom) . |
ClientConfiguration |
withSignerOverride(java.lang.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(java.lang.String userAgent)
Sets the HTTP user agent header used in requests and returns the updated ClientConfiguration
object.
|
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
private static final boolean DEFAULT_USE_EXPECT_CONTINUE
public static final java.lang.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 boolean DEFAULT_TCP_KEEP_ALIVE
public static final boolean DEFAULT_THROTTLE_RETRIES
public static final int DEFAULT_RESPONSE_METADATA_CACHE_SIZE
private java.lang.String userAgent
private int maxErrorRetry
private RetryPolicy retryPolicy
private java.net.InetAddress localAddress
private Protocol protocol
The default configuration is to use HTTPS for all requests for increased security.
private java.lang.String proxyHost
private int proxyPort
private java.lang.String proxyUsername
private java.lang.String proxyPassword
private java.lang.String proxyDomain
private java.lang.String proxyWorkstation
private boolean preemptiveBasicProxyAuth
private int maxConnections
private int socketTimeout
private int connectionTimeout
private int requestTimeout
private int clientExecutionTimeout
private boolean throttleRetries
private int socketSendBufferSizeHint
private int socketReceiveBufferSizeHint
private boolean useReaper
IdleConnectionReaper
to manage stale connections. A
reason for not running the IdleConnectionReaper
can be if running in an environment
where the modifyThread and modifyThreadGroup permissions are not allowed.private boolean useGzip
private java.lang.String signerOverride
private long connectionTTL
private long connectionMaxIdleMillis
private boolean tcpKeepAlive
Actual TCP KeepAlive values (timeout, number of packets, etc) are configured via the operating system (sysctl on Linux, and Registry values on Windows).
private int responseMetadataCacheSize
Response metadata is typically used for troubleshooting issues with AWS support staff when services aren't acting as expected.
private DnsResolver dnsResolver
private java.security.SecureRandom secureRandom
SecureRandom
configured by the user; or the JDK default will be used
if it is set to null or not explicitly configured.private boolean useExpectContinue
The detail of HTTP Expect Continue is defined at Use of the 100 (Continue) Status. Setting this as false will reduce latency when you want to send small size of payload. It is highly recommended to use the default value if you want to transfer a large amount of data to the server, such as uploading a big file to S3 bucket.
private final ApacheHttpClientConfig apacheHttpClientConfig
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.public java.lang.String getUserAgent()
public void setUserAgent(java.lang.String userAgent)
userAgent
- The user agent string to use when sending requests.public ClientConfiguration withUserAgent(java.lang.String userAgent)
userAgent
- The user agent string to use when sending requests.public java.net.InetAddress getLocalAddress()
public void setLocalAddress(java.net.InetAddress localAddress)
localAddress
- The local address the client will bind to.public ClientConfiguration withLocalAddress(java.net.InetAddress localAddress)
localAddress
- The local address the client will bind to.private java.lang.String getSystemProperty(java.lang.String property)
private java.lang.String getProxyHostProperty()
this.getProtocol()
: i.e. if protocol is https, returns
the value of the system property https.proxyHost, otherwise
returns value of http.proxyHost.public java.lang.String getProxyHost()
this.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(java.lang.String proxyHost)
proxyHost
- The proxy host the client will connect through.public ClientConfiguration withProxyHost(java.lang.String proxyHost)
proxyHost
- The proxy host the client will connect through.private int getProxyPortProperty()
this.getProtocol()
: i.e. if protocol is https, returns
the value of the system property https.proxyPort, otherwise
returns value of http.proxyPort. Defaults to this.proxyPort
if the system property is not set with a valid port number.public int getProxyPort()
this.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.private java.lang.String getProxyUsernameProperty()
this.getProtocol()
: i.e. if protocol is https, returns
the value of the system property https.proxyUser, otherwise
returns value of http.proxyUser.public java.lang.String getProxyUsername()
this.getProtocol()
:
i.e. if protocol is https, returns the value of the system
property https.proxyUsername, otherwise returns value of
http.proxyUsername.public void setProxyUsername(java.lang.String proxyUsername)
proxyUsername
- The proxy user name to use if connecting through a proxy.public ClientConfiguration withProxyUsername(java.lang.String proxyUsername)
proxyUsername
- The proxy user name to use if connecting through a proxy.private java.lang.String getProxyPasswordProperty()
this.getProtocol()
: i.e. if protocol is https, returns
the value of the system property https.proxyPassword, otherwise
returns value of http.proxyPassword.public java.lang.String getProxyPassword()
this.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(java.lang.String proxyPassword)
proxyPassword
- The password to use when connecting through a proxy.public ClientConfiguration withProxyPassword(java.lang.String proxyPassword)
proxyPassword
- The password to use when connecting through a proxy.public java.lang.String getProxyDomain()
public void setProxyDomain(java.lang.String proxyDomain)
proxyDomain
- The optional Windows domain name for configuring an NTLM proxy.public ClientConfiguration withProxyDomain(java.lang.String proxyDomain)
proxyDomain
- The optional Windows domain name for configuring an NTLM proxy.public java.lang.String getProxyWorkstation()
public void setProxyWorkstation(java.lang.String proxyWorkstation)
proxyWorkstation
- The optional Windows workstation name for configuring NTLM proxy support.public ClientConfiguration withProxyWorkstation(java.lang.String proxyWorkstation)
proxyWorkstation
- The optional Windows workstation name for configuring NTLM proxy support.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 is 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 is 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 null disables this feature for this request.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 null disables this feature for this request.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 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 java.lang.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(java.lang.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(java.lang.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(java.lang.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 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 int getResponseMetadataCacheSize()
public void setResponseMetadataCacheSize(int responseMetadataCacheSize)
responseMetadataCacheSize
- maximum cache size.public ClientConfiguration withResponseMetadataCacheSize(int responseMetadataCacheSize)
responseMetadataCacheSize
- maximum cache size.public ApacheHttpClientConfig getApacheHttpClientConfig()
public java.security.SecureRandom getSecureRandom()
SecureRandom
configured by the user; or the JDK default if it
is null.public void setSecureRandom(java.security.SecureRandom secureRandom)
SecureRandom
to be used by the SDK.public ClientConfiguration withSecureRandom(java.security.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.