DirectConnectionConfig Class
- java.
lang. Object - com.
azure. cosmos. DirectConnectionConfig
- com.
public final class DirectConnectionConfig
Represents the connection config with DIRECT associated with Cosmos Client in the Azure Cosmos DB database service. For performance tips on how to optimize Direct connection configuration, refer to performance tips guide: Performance tips guide
Constructor Summary
Constructor | Description |
---|---|
DirectConnectionConfig() |
Constructor |
Method Summary
Modifier and Type | Method and Description |
---|---|
Duration |
getConnectTimeout()
Gets the connect timeout for direct client, represents timeout for establishing connections with an endpoint. |
static
Direct |
getDefaultConfig()
Gets the default DIRECT connection configuration. |
Duration |
getIdleConnectionTimeout()
Gets the idle connection timeout for direct client Default value is Duration#ZERO Direct client doesn't close a single connection to an endpoint by default unless specified. |
Duration |
getIdleEndpointTimeout()
Gets the idle endpoint timeout Default value is 1 hour. |
int |
getMaxConnectionsPerEndpoint()
Gets the max connections per endpoint This represents the size of connection pool for a specific endpoint Default value is 130 |
int |
getMaxRequestsPerConnection()
Gets the max requests per connection This represents the number of requests that will be queued on a single connection for a specific endpoint Default value is 30 |
Duration |
getNetworkRequestTimeout()
Gets the network request timeout interval (time to wait for response from network peer). |
boolean |
isConnectionEndpointRediscoveryEnabled()
Gets a value indicating whether Direct TCP connection endpoint rediscovery is enabled. |
Direct |
setConnectTimeout(Duration connectTimeout)
Sets the connect timeout for direct client, represents timeout for establishing connections with an endpoint. |
Direct |
setConnectionEndpointRediscoveryEnabled(boolean connectionEndpointRediscoveryEnabled)
Sets a value indicating whether Direct TCP connection endpoint rediscovery should be enabled. |
Direct |
setIdleConnectionTimeout(Duration idleConnectionTimeout)
Sets the idle connection timeout Default value is Duration#ZERO Direct client doesn't close a single connection to an endpoint by default unless specified. |
Direct |
setIdleEndpointTimeout(Duration idleEndpointTimeout)
Sets the idle endpoint timeout Default value is 1 hour. |
Direct |
setMaxConnectionsPerEndpoint(int maxConnectionsPerEndpoint)
Sets the max connections per endpoint This represents the size of connection pool for a specific endpoint Default value is 130 |
Direct |
setMaxRequestsPerConnection(int maxRequestsPerConnection)
Sets the max requests per connection This represents the number of requests that will be queued on a single connection for a specific endpoint Default value is 30 |
Direct |
setNetworkRequestTimeout(Duration networkRequestTimeout)
Sets the network request timeout interval (time to wait for response from network peer). |
String | toString() |
Methods inherited from java.lang.Object
Constructor Details
DirectConnectionConfig
public DirectConnectionConfig()
Constructor
Method Details
getConnectTimeout
public Duration getConnectTimeout()
Gets the connect timeout for direct client, represents timeout for establishing connections with an endpoint. Configures timeout for underlying Netty Channel ChannelOption#CONNECT_TIMEOUT_MILLIS By default, the connect timeout is 5 seconds.
Returns:
getDefaultConfig
public static DirectConnectionConfig getDefaultConfig()
Gets the default DIRECT connection configuration.
Returns:
getIdleConnectionTimeout
public Duration getIdleConnectionTimeout()
Gets the idle connection timeout for direct client Default value is Duration#ZERO Direct client doesn't close a single connection to an endpoint by default unless specified.
Returns:
getIdleEndpointTimeout
public Duration getIdleEndpointTimeout()
Gets the idle endpoint timeout Default value is 1 hour. If set to Duration#ZERO, idle endpoint check will be disabled. If there are no requests to a specific endpoint for idle endpoint timeout duration, direct client closes all connections to that endpoint to save resources and I/O cost.
Returns:
getMaxConnectionsPerEndpoint
public int getMaxConnectionsPerEndpoint()
Gets the max connections per endpoint This represents the size of connection pool for a specific endpoint Default value is 130
Returns:
getMaxRequestsPerConnection
public int getMaxRequestsPerConnection()
Gets the max requests per connection This represents the number of requests that will be queued on a single connection for a specific endpoint Default value is 30
Returns:
getNetworkRequestTimeout
public Duration getNetworkRequestTimeout()
Gets the network request timeout interval (time to wait for response from network peer). Default value is 5 seconds
Returns:
isConnectionEndpointRediscoveryEnabled
public boolean isConnectionEndpointRediscoveryEnabled()
Gets a value indicating whether Direct TCP connection endpoint rediscovery is enabled.
The connection endpoint rediscovery feature is designed to reduce and spread-out latency spikes that may occur during maintenance operations. By default, connection endpoint rediscovery is enabled.
Returns:
true
if Direct TCP connection endpoint rediscovery is enabled; false
otherwise.setConnectTimeout
public DirectConnectionConfig setConnectTimeout(Duration connectTimeout)
Sets the connect timeout for direct client, represents timeout for establishing connections with an endpoint. Configures timeout for underlying Netty Channel ChannelOption#CONNECT_TIMEOUT_MILLIS By default, the connect timeout is 5 seconds.
Parameters:
Returns:
setConnectionEndpointRediscoveryEnabled
public DirectConnectionConfig setConnectionEndpointRediscoveryEnabled(boolean connectionEndpointRediscoveryEnabled)
Sets a value indicating whether Direct TCP connection endpoint rediscovery should be enabled.
The connection endpoint rediscovery feature is designed to reduce and spread-out latency spikes that may occur during maintenance operations. By default, connection endpoint rediscovery is enabled.
Parameters:
true
if connection endpoint rediscovery is enabled;
false
otherwise.
Returns:
setIdleConnectionTimeout
public DirectConnectionConfig setIdleConnectionTimeout(Duration idleConnectionTimeout)
Sets the idle connection timeout Default value is Duration#ZERO Direct client doesn't close a single connection to an endpoint by default unless specified.
Parameters:
Returns:
setIdleEndpointTimeout
public DirectConnectionConfig setIdleEndpointTimeout(Duration idleEndpointTimeout)
Sets the idle endpoint timeout Default value is 1 hour. If set to Duration#ZERO, idle endpoint check will be disabled. If there are no requests to a specific endpoint for idle endpoint timeout duration, direct client closes all connections to that endpoint to save resources and I/O cost.
Parameters:
Returns:
setMaxConnectionsPerEndpoint
public DirectConnectionConfig setMaxConnectionsPerEndpoint(int maxConnectionsPerEndpoint)
Sets the max connections per endpoint This represents the size of connection pool for a specific endpoint Default value is 130
Parameters:
Returns:
setMaxRequestsPerConnection
public DirectConnectionConfig setMaxRequestsPerConnection(int maxRequestsPerConnection)
Sets the max requests per connection This represents the number of requests that will be queued on a single connection for a specific endpoint Default value is 30
Parameters:
Returns:
setNetworkRequestTimeout
public DirectConnectionConfig setNetworkRequestTimeout(Duration networkRequestTimeout)
Sets the network request timeout interval (time to wait for response from network peer). Default value is 5 seconds. It only allows values ?1s and ?10s. (backend allows requests to take up-to 5 seconds processing time - 5 seconds buffer so 10 seconds in total for transport is more than sufficient). Attention! Please adjust this value with caution. This config represents the max time allowed to wait for and consume a service response after the request has been written to the network connection. Setting a value too low can result in having not enough time to wait for the service response - which could cause too aggressive retries and degrade performance. Setting a value too high can result in fewer retries and reduce chances of success by retries.
Parameters:
Returns:
toString
public String toString()
Overrides:
DirectConnectionConfig.toString()Applies to
Azure SDK for Java