public final class DirectConnectionConfig extends Object
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 guideConstructor and Description |
---|
DirectConnectionConfig()
Constructor
|
Modifier and Type | Method and Description |
---|---|
Duration |
getConnectTimeout()
Gets the connect timeout for direct client,
represents timeout for establishing connections with an endpoint.
|
static DirectConnectionConfig |
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
|
boolean |
isConnectionEndpointRediscoveryEnabled()
Gets a value indicating whether Direct TCP connection endpoint rediscovery is enabled.
|
DirectConnectionConfig |
setConnectionEndpointRediscoveryEnabled(boolean connectionEndpointRediscoveryEnabled)
Sets a value indicating whether Direct TCP connection endpoint rediscovery should be enabled.
|
DirectConnectionConfig |
setConnectTimeout(Duration connectTimeout)
Sets the connect timeout for direct client,
represents timeout for establishing connections with an endpoint.
|
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. |
DirectConnectionConfig |
setIdleEndpointTimeout(Duration idleEndpointTimeout)
Sets the idle endpoint timeout
Default value is 1 hour.
|
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
|
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
|
String |
toString() |
public boolean isConnectionEndpointRediscoveryEnabled()
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 disabled.
true
if Direct TCP connection endpoint rediscovery is enabled; false
otherwise.public DirectConnectionConfig setConnectionEndpointRediscoveryEnabled(boolean connectionEndpointRediscoveryEnabled)
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 disabled.
connectionEndpointRediscoveryEnabled
- true
if connection endpoint rediscovery is enabled; false
otherwise.public static DirectConnectionConfig getDefaultConfig()
public Duration getConnectTimeout()
ChannelOption.CONNECT_TIMEOUT_MILLIS
By default, the connect timeout is 5 seconds.public DirectConnectionConfig setConnectTimeout(Duration connectTimeout)
ChannelOption.CONNECT_TIMEOUT_MILLIS
By default, the connect timeout is 5 seconds.connectTimeout
- the connection timeoutDirectConnectionConfig
public Duration getIdleConnectionTimeout()
Duration.ZERO
Direct client doesn't close a single connection to an endpoint
by default unless specified.public DirectConnectionConfig setIdleConnectionTimeout(Duration idleConnectionTimeout)
Duration.ZERO
Direct client doesn't close a single connection to an endpoint
by default unless specified.idleConnectionTimeout
- idle connection timeoutDirectConnectionConfig
public Duration getIdleEndpointTimeout()
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.public DirectConnectionConfig setIdleEndpointTimeout(Duration idleEndpointTimeout)
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.idleEndpointTimeout
- the idle endpoint timeoutDirectConnectionConfig
public int getMaxConnectionsPerEndpoint()
public DirectConnectionConfig setMaxConnectionsPerEndpoint(int maxConnectionsPerEndpoint)
maxConnectionsPerEndpoint
- the max connections per endpointDirectConnectionConfig
public int getMaxRequestsPerConnection()
public DirectConnectionConfig setMaxRequestsPerConnection(int maxRequestsPerConnection)
maxRequestsPerConnection
- the max requests per endpointDirectConnectionConfig
Copyright © 2021 Microsoft Corporation. All rights reserved.