Package software.amazon.awssdk.crt.http
Class HttpClientConnectionManagerOptions
- java.lang.Object
-
- software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions
-
public class HttpClientConnectionManagerOptions extends Object
Contains all the configuration options for a HttpConnectionPoolManager instance
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_BUFFER_SIZE
static int
DEFAULT_MAX_CONNECTIONS
static long
DEFAULT_MAX_WINDOW_SIZE
-
Constructor Summary
Constructors Constructor Description HttpClientConnectionManagerOptions()
Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
getBufferSize()
Deprecated.ClientBootstrap
getClientBootstrap()
Gets the client bootstrap instance to use to create the pool's connectionslong
getConnectionAcquisitionTimeoutInMilliseconds()
HttpVersion
getExpectedHttpVersion()
HttpProxyEnvironmentVariableSetting
getHttpProxyEnvironmentVariableSetting()
long
getMaxConnectionIdleInMilliseconds()
int
getMaxConnections()
long
getMaxPendingConnectionAcquisitions()
HttpMonitoringOptions
getMonitoringOptions()
int
getPort()
HttpProxyOptions
getProxyOptions()
SocketOptions
getSocketOptions()
TlsConnectionOptions
getTlsConnectionOptions()
TlsContext
getTlsContext()
URI
getUri()
long
getWindowSize()
boolean
isManualWindowManagement()
void
validateOptions()
Validate the connection manager options are valid to use.HttpClientConnectionManagerOptions
withBufferSize(int bufferSize)
Deprecated.Sets the IO buffer size to use for connections in the connection poolHttpClientConnectionManagerOptions
withClientBootstrap(ClientBootstrap clientBootstrap)
Sets the client bootstrap instance to use to create the pool's connectionsHttpClientConnectionManagerOptions
withConnectionAcquisitionTimeoutInMilliseconds(int connectionAcquisitionTimeoutInMilliseconds)
If set,HttpClientConnectionManager.acquireConnection()
will give up after waiting this long for a connection from the pool, failing with error AWS_ERROR_HTTP_CONNECTION_MANAGER_ACQUISITION_TIMEOUT.HttpClientConnectionManagerOptions
withExpectedHttpVersion(HttpVersion expectedHttpVersion)
Set the expected protocol version of the connection to be made, default is HTTP/1.1HttpClientConnectionManagerOptions
withManualWindowManagement(boolean manualWindowManagement)
If set to true, then you must manage the read backpressure mechanism.HttpClientConnectionManagerOptions
withMaxConnectionIdleInMilliseconds(long maxConnectionIdleInMilliseconds)
Sets maximum amount of time, in milliseconds, that the connection can be idle in the manager before getting culled by the managerHttpClientConnectionManagerOptions
withMaxConnections(int maxConnections)
Sets the maximum number of connections allowed in the connection poolHttpClientConnectionManagerOptions
withMaxPendingConnectionAcquisitions(int maxPendingConnectionAcquisitions)
If set,HttpClientConnectionManager.acquireConnection()
will fail with AWS_ERROR_HTTP_CONNECTION_MANAGER_MAX_PENDING_ACQUISITIONS_EXCEEDED if there are already pending acquisitions equal to `maxPendingConnectionAcquisitions`.HttpClientConnectionManagerOptions
withMonitoringOptions(HttpMonitoringOptions monitoringOptions)
Sets the monitoring options for connections in the connection poolHttpClientConnectionManagerOptions
withPort(int port)
Sets the port to connect to for connections in the connection pool.HttpClientConnectionManagerOptions
withProxyEnvironmentVariableSetting(HttpProxyEnvironmentVariableSetting httpProxyEnvironmentVariableSetting)
Optional.HttpClientConnectionManagerOptions
withProxyOptions(HttpProxyOptions proxyOptions)
Sets the proxy options for connections in the connection poolHttpClientConnectionManagerOptions
withSocketOptions(SocketOptions socketOptions)
Sets the socket options to use for connections in the connection poolHttpClientConnectionManagerOptions
withTlsConnectionOptions(TlsConnectionOptions tlsConnectionOptions)
Sets the connection-specific TLS options to use for connections in the connection pool.HttpClientConnectionManagerOptions
withTlsContext(TlsContext tlsContext)
Sets the tls context to use for connections in the connection poolHttpClientConnectionManagerOptions
withUri(URI uri)
Sets the URI to use for connections in the connection poolHttpClientConnectionManagerOptions
withWindowSize(long windowSize)
Sets the starting size of each HTTP stream's flow-control window.
-
-
-
Field Detail
-
DEFAULT_MAX_BUFFER_SIZE
public static final int DEFAULT_MAX_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_MAX_WINDOW_SIZE
public static final long DEFAULT_MAX_WINDOW_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_MAX_CONNECTIONS
- See Also:
- Constant Field Values
-
-
Method Detail
-
withClientBootstrap
public HttpClientConnectionManagerOptions withClientBootstrap(ClientBootstrap clientBootstrap)
Sets the client bootstrap instance to use to create the pool's connections- Parameters:
clientBootstrap
- ClientBootstrap to use- Returns:
- this
-
getClientBootstrap
public ClientBootstrap getClientBootstrap()
Gets the client bootstrap instance to use to create the pool's connections- Returns:
- ClientBootstrap used by this connection manager
-
withSocketOptions
public HttpClientConnectionManagerOptions withSocketOptions(SocketOptions socketOptions)
Sets the socket options to use for connections in the connection pool- Parameters:
socketOptions
- The socket options to use for all connections in the manager- Returns:
- this
-
getSocketOptions
public SocketOptions getSocketOptions()
- Returns:
- the socket options to use for connections in the connection pool
-
withTlsContext
public HttpClientConnectionManagerOptions withTlsContext(TlsContext tlsContext)
Sets the tls context to use for connections in the connection pool- Parameters:
tlsContext
- The TlsContext to use- Returns:
- this
-
getTlsContext
public TlsContext getTlsContext()
- Returns:
- the tls context used by connections in the connection pool
-
withTlsConnectionOptions
public HttpClientConnectionManagerOptions withTlsConnectionOptions(TlsConnectionOptions tlsConnectionOptions)
Sets the connection-specific TLS options to use for connections in the connection pool. Either TLS context or TLS connection options will be enough to set up TLS connection. If both set, an exception will be raised.- Parameters:
tlsConnectionOptions
- The TlsConnectionOptions to use- Returns:
- this
-
getTlsConnectionOptions
public TlsConnectionOptions getTlsConnectionOptions()
- Returns:
- the tls context used by connections in the connection pool
-
withWindowSize
public HttpClientConnectionManagerOptions withWindowSize(long windowSize)
Sets the starting size of each HTTP stream's flow-control window. This is only used when "manual window management" is enabled.- Parameters:
windowSize
- The initial window size for each HTTP stream- Returns:
- this
- See Also:
withManualWindowManagement(boolean)
-
getWindowSize
public long getWindowSize()
- Returns:
- The starting size of each HTTP stream's flow-control window.
-
withBufferSize
public HttpClientConnectionManagerOptions withBufferSize(int bufferSize)
Deprecated.Sets the IO buffer size to use for connections in the connection pool- Parameters:
bufferSize
- Size of I/O buffer per connection- Returns:
- this
-
getBufferSize
public int getBufferSize()
Deprecated.- Returns:
- the IO buffer size to use for connections in the connection pool
-
withUri
public HttpClientConnectionManagerOptions withUri(URI uri)
Sets the URI to use for connections in the connection pool- Parameters:
uri
- The endpoint URI to connect to- Returns:
- this
-
getUri
public URI getUri()
- Returns:
- the URI to use for connections in the connection pool
-
withPort
public HttpClientConnectionManagerOptions withPort(int port)
Sets the port to connect to for connections in the connection pool. For 32bit values exceeding Integer.MAX_VALUE use two's complement (i.e. -1 == 0xFFFFFFFF).- Parameters:
port
- The port to connect to- Returns:
- this
-
getPort
public int getPort()
- Returns:
- the port to connect to for connections in the connection pool. Returns -1 if none has been explicitly set. Note that two's complement is used for 32bit values exceeding Integer.MAX_VALUE (i.e. -1 == 0xFFFFFFFF).
-
withMaxConnections
public HttpClientConnectionManagerOptions withMaxConnections(int maxConnections)
Sets the maximum number of connections allowed in the connection pool- Parameters:
maxConnections
- maximum number of connections to pool- Returns:
- this
-
getMaxConnections
public int getMaxConnections()
- Returns:
- the maximum number of connections allowed in the connection pool
-
withProxyOptions
public HttpClientConnectionManagerOptions withProxyOptions(HttpProxyOptions proxyOptions)
Sets the proxy options for connections in the connection pool- Parameters:
proxyOptions
- HttpProxyOptions for this connection manager, or null to disable proxying- Returns:
- this
-
getProxyOptions
public HttpProxyOptions getProxyOptions()
- Returns:
- the proxy options for connections in the connection pool
-
withProxyEnvironmentVariableSetting
public HttpClientConnectionManagerOptions withProxyEnvironmentVariableSetting(HttpProxyEnvironmentVariableSetting httpProxyEnvironmentVariableSetting)
Optional. Sets how proxy is fetched from the environment. Reading proxy configuration from environment is disabled if this is NULL for backward compatibility. Only works when proxyOptions is not set. The proxy settings follow the following precedence 1. Configured Proxy Setting 2. Environment (if enabled) 3. No proxy- Parameters:
httpProxyEnvironmentVariableSetting
- for this connection manager- Returns:
- this
-
getHttpProxyEnvironmentVariableSetting
public HttpProxyEnvironmentVariableSetting getHttpProxyEnvironmentVariableSetting()
- Returns:
- the proxy environment variable setting
-
isManualWindowManagement
public boolean isManualWindowManagement()
- Returns:
- true if manual window management is used, false otherwise
- See Also:
withManualWindowManagement(boolean)
-
withManualWindowManagement
public HttpClientConnectionManagerOptions withManualWindowManagement(boolean manualWindowManagement)
If set to true, then you must manage the read backpressure mechanism. You should only use this if you're allowing http response body data to escape the callbacks. E.g. you're putting the data into a queue for another thread to process and need to make sure the memory usage is bounded (e.g. reactive streams).When enabled, each HttpStream has a flow-control window that shrinks as response body data is downloaded (headers do not affect the window).
withWindowSize(long)
determines the starting size of each HttpStream's window, in bytes. Data stops downloading whenever the window reaches zero. Increment the window to keep data flowing by callingHttpStreamBase.incrementWindow(int)
, or by returning a size fromHttpStreamResponseHandler.onResponseBody(software.amazon.awssdk.crt.http.HttpStream, byte[])
. Maintain a larger window to keep up a high download throughput, or use a smaller window to limit how much data could get buffered in memory.- Parameters:
manualWindowManagement
- true to enable manual window management, false to use automatic window management- Returns:
- this
-
withExpectedHttpVersion
public HttpClientConnectionManagerOptions withExpectedHttpVersion(HttpVersion expectedHttpVersion)
Set the expected protocol version of the connection to be made, default is HTTP/1.1- Parameters:
expectedHttpVersion
- The expected protocol version of the connection made- Returns:
- this
-
getExpectedHttpVersion
public HttpVersion getExpectedHttpVersion()
- Returns:
- Return the expected HTTP protocol version.
-
withMaxConnectionIdleInMilliseconds
public HttpClientConnectionManagerOptions withMaxConnectionIdleInMilliseconds(long maxConnectionIdleInMilliseconds)
Sets maximum amount of time, in milliseconds, that the connection can be idle in the manager before getting culled by the manager- Parameters:
maxConnectionIdleInMilliseconds
- How long to allow connections to be idle before reaping them- Returns:
- this
-
getConnectionAcquisitionTimeoutInMilliseconds
public long getConnectionAcquisitionTimeoutInMilliseconds()
- Returns:
- Return the connection acquisition timeout in miliseconds
-
withConnectionAcquisitionTimeoutInMilliseconds
public HttpClientConnectionManagerOptions withConnectionAcquisitionTimeoutInMilliseconds(int connectionAcquisitionTimeoutInMilliseconds)
If set,HttpClientConnectionManager.acquireConnection()
will give up after waiting this long for a connection from the pool, failing with error AWS_ERROR_HTTP_CONNECTION_MANAGER_ACQUISITION_TIMEOUT.- Parameters:
connectionAcquisitionTimeoutInMilliseconds
- timeout in milliseconds.- Returns:
- this
-
getMaxPendingConnectionAcquisitions
public long getMaxPendingConnectionAcquisitions()
- Returns:
- Return the max pending connection acquisitions
-
withMaxPendingConnectionAcquisitions
public HttpClientConnectionManagerOptions withMaxPendingConnectionAcquisitions(int maxPendingConnectionAcquisitions)
If set,HttpClientConnectionManager.acquireConnection()
will fail with AWS_ERROR_HTTP_CONNECTION_MANAGER_MAX_PENDING_ACQUISITIONS_EXCEEDED if there are already pending acquisitions equal to `maxPendingConnectionAcquisitions`.- Parameters:
maxPendingConnectionAcquisitions
- maximum pending acquisitions allowed- Returns:
- this
-
getMaxConnectionIdleInMilliseconds
public long getMaxConnectionIdleInMilliseconds()
- Returns:
- How long to allow connections to be idle before reaping them
-
withMonitoringOptions
public HttpClientConnectionManagerOptions withMonitoringOptions(HttpMonitoringOptions monitoringOptions)
Sets the monitoring options for connections in the connection pool- Parameters:
monitoringOptions
- Monitoring options for this connection manager, or null to disable monitoring- Returns:
- this
-
getMonitoringOptions
public HttpMonitoringOptions getMonitoringOptions()
- Returns:
- the monitoring options for connections in the connection pool
-
validateOptions
public void validateOptions()
Validate the connection manager options are valid to use. Throw exceptions if not.
-
-