Package com.azure.cosmos
Class DirectConnectionConfig
java.lang.Object
com.azure.cosmos.DirectConnectionConfig
Represents the connection config with
ConnectionMode.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
-
Method Summary
Modifier and TypeMethodDescriptionGets the connect timeout for direct client, represents timeout for establishing connections with an endpoint.static DirectConnectionConfig
Gets the default DIRECT connection configuration.Gets the idle connection timeout for direct client Default value isDuration.ZERO
Direct client doesn't close a single connection to an endpoint by default unless specified.Gets the idle endpoint timeout Default value is 1 hour.int
Gets the max connections per endpoint This represents the size of connection pool for a specific endpoint Default value is 130int
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 30Gets the network request timeout interval (time to wait for response from network peer).boolean
Gets a value indicating whether Direct TCP connection endpoint rediscovery is enabled.setConnectionEndpointRediscoveryEnabled
(boolean connectionEndpointRediscoveryEnabled) Sets a value indicating whether Direct TCP connection endpoint rediscovery should be enabled.setConnectTimeout
(Duration connectTimeout) Sets the connect timeout for direct client, represents timeout for establishing connections with an endpoint.setIdleConnectionTimeout
(Duration idleConnectionTimeout) Sets the idle connection timeout Default value isDuration.ZERO
Direct client doesn't close a single connection to an endpoint by default unless specified.setIdleEndpointTimeout
(Duration idleEndpointTimeout) Sets the idle endpoint timeout Default value is 1 hour.setMaxConnectionsPerEndpoint
(int maxConnectionsPerEndpoint) Sets the max connections per endpoint This represents the size of connection pool for a specific endpoint Default value is 130setMaxRequestsPerConnection
(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 30setNetworkRequestTimeout
(Duration networkRequestTimeout) Sets the network request timeout interval (time to wait for response from network peer).toString()
-
Constructor Details
-
DirectConnectionConfig
public DirectConnectionConfig()Constructor
-
-
Method Details
-
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.
-
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:
connectionEndpointRediscoveryEnabled
-true
if connection endpoint rediscovery is enabled;false
otherwise.- Returns:
- the DirectConnectionConfig.
-
getDefaultConfig
Gets the default DIRECT connection configuration.- Returns:
- the default direct connection configuration.
-
getConnectTimeout
Gets the connect timeout for direct client, represents timeout for establishing connections with an endpoint. Configures timeout for underlying Netty ChannelChannelOption.CONNECT_TIMEOUT_MILLIS
By default, the connect timeout is 5 seconds.- Returns:
- direct connect timeout
-
setConnectTimeout
Sets the connect timeout for direct client, represents timeout for establishing connections with an endpoint. Configures timeout for underlying Netty ChannelChannelOption.CONNECT_TIMEOUT_MILLIS
By default, the connect timeout is 5 seconds.- Parameters:
connectTimeout
- the connection timeout- Returns:
- the
DirectConnectionConfig
-
getIdleConnectionTimeout
Gets the idle connection timeout for direct client Default value isDuration.ZERO
Direct client doesn't close a single connection to an endpoint by default unless specified.- Returns:
- idle connection timeout
-
setIdleConnectionTimeout
Sets the idle connection timeout Default value isDuration.ZERO
Direct client doesn't close a single connection to an endpoint by default unless specified.- Parameters:
idleConnectionTimeout
- idle connection timeout- Returns:
- the
DirectConnectionConfig
-
getIdleEndpointTimeout
Gets the idle endpoint timeout Default value is 1 hour. If set toDuration.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:
- the idle endpoint timeout
-
setIdleEndpointTimeout
Sets the idle endpoint timeout Default value is 1 hour. If set toDuration.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:
idleEndpointTimeout
- the idle endpoint timeout- Returns:
- the
DirectConnectionConfig
-
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:
- the max connections per endpoint
-
setMaxConnectionsPerEndpoint
Sets the max connections per endpoint This represents the size of connection pool for a specific endpoint Default value is 130- Parameters:
maxConnectionsPerEndpoint
- the max connections per endpoint- Returns:
- the
DirectConnectionConfig
-
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:
- the max requests per endpoint
-
setMaxRequestsPerConnection
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:
maxRequestsPerConnection
- the max requests per endpoint- Returns:
- the
DirectConnectionConfig
-
getNetworkRequestTimeout
Gets the network request timeout interval (time to wait for response from network peer). Default value is 5 seconds- Returns:
- the network request timeout interval
-
setNetworkRequestTimeout
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:
networkRequestTimeout
- the network request timeout interval.- Returns:
- the
DirectConnectionConfig
-
toString
-