public final class ConnectionPolicy extends Object
Constructor and Description |
---|
ConnectionPolicy()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ConnectionMode |
connectionMode()
Gets the connection mode used in the client.
|
ConnectionPolicy |
connectionMode(ConnectionMode connectionMode)
Sets the connection mode used in the client.
|
static ConnectionPolicy |
defaultPolicy()
Gets the default connection policy.
|
boolean |
enableEndpointDiscovery()
Gets the flag to enable endpoint discovery for geo-replicated database accounts.
|
ConnectionPolicy |
enableEndpointDiscovery(boolean enableEndpointDiscovery)
Sets the flag to enable endpoint discovery for geo-replicated database accounts.
|
Boolean |
enableReadRequestsFallback()
Gets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.
|
ConnectionPolicy |
enableReadRequestsFallback(Boolean enableReadRequestsFallback)
Sets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.
|
int |
idleConnectionTimeoutInMillis()
Gets the value of the timeout for an idle connection, the default is 60
seconds.
|
ConnectionPolicy |
idleConnectionTimeoutInMillis(int idleConnectionTimeoutInMillis)
sets the value of the timeout for an idle connection.
|
int |
maxPoolSize()
Gets the value of the connection pool size the client is using.
|
ConnectionPolicy |
maxPoolSize(int maxPoolSize)
Sets the value of the connection pool size, the default
is 1000.
|
List<String> |
preferredLocations()
Gets the preferred locations for geo-replicated database accounts
|
ConnectionPolicy |
preferredLocations(List<String> preferredLocations)
Sets the preferred locations for geo-replicated database accounts.
|
InetSocketAddress |
proxy()
Gets the InetSocketAddress of proxy server.
|
ConnectionPolicy |
proxy(String proxyHost,
int proxyPort)
This will create the InetSocketAddress for proxy server,
all the requests to cosmoDB will route from this address.
|
int |
requestTimeoutInMillis()
Gets the request timeout (time to wait for response from network peer) in
milliseconds.
|
ConnectionPolicy |
requestTimeoutInMillis(int requestTimeoutInMillis)
Sets the request timeout (time to wait for response from network peer) in
milliseconds.
|
RetryOptions |
retryOptions()
Gets the retry policy options associated with the DocumentClient instance.
|
ConnectionPolicy |
retryOptions(RetryOptions retryOptions)
Sets the retry policy options associated with the DocumentClient instance.
|
String |
toString() |
String |
userAgentSuffix()
Gets the value of user-agent suffix.
|
ConnectionPolicy |
userAgentSuffix(String userAgentSuffix)
sets the value of the user-agent suffix.
|
boolean |
usingMultipleWriteLocations()
Gets the flag to enable writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.
|
ConnectionPolicy |
usingMultipleWriteLocations(boolean usingMultipleWriteLocations)
Sets the flag to enable writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.
|
public static ConnectionPolicy defaultPolicy()
public int requestTimeoutInMillis()
public ConnectionPolicy requestTimeoutInMillis(int requestTimeoutInMillis)
requestTimeoutInMillis
- the request timeout in milliseconds.public ConnectionMode connectionMode()
public ConnectionPolicy connectionMode(ConnectionMode connectionMode)
connectionMode
- the connection mode.public int maxPoolSize()
public ConnectionPolicy maxPoolSize(int maxPoolSize)
maxPoolSize
- The value of the connection pool size.public int idleConnectionTimeoutInMillis()
public ConnectionPolicy idleConnectionTimeoutInMillis(int idleConnectionTimeoutInMillis)
idleConnectionTimeoutInMillis
- the timeout for an idle connection in seconds.public String userAgentSuffix()
public ConnectionPolicy userAgentSuffix(String userAgentSuffix)
userAgentSuffix
- The value to be appended to the user-agent header, this is
used for monitoring purposes.public RetryOptions retryOptions()
public ConnectionPolicy retryOptions(RetryOptions retryOptions)
Properties in the RetryOptions class allow application to customize the built-in retry policies. This property is optional. When it's not set, the SDK uses the default values for configuring the retry policies. See RetryOptions class for more details.
retryOptions
- the RetryOptions instance.public boolean enableEndpointDiscovery()
public ConnectionPolicy enableEndpointDiscovery(boolean enableEndpointDiscovery)
When EnableEndpointDiscovery is true, the SDK will automatically discover the current write and read regions to ensure requests are sent to the correct region based on the capability of the region and the user's preference.
The default value for this property is true indicating endpoint discovery is enabled.
enableEndpointDiscovery
- true if EndpointDiscovery is enabled.public boolean usingMultipleWriteLocations()
public Boolean enableReadRequestsFallback()
enableEndpointDiscovery
is true
2. the Azure Cosmos DB account has more than one regionpublic ConnectionPolicy usingMultipleWriteLocations(boolean usingMultipleWriteLocations)
usingMultipleWriteLocations
- flag to enable writes on any locations (regions) for geo-replicated database accounts.public ConnectionPolicy enableReadRequestsFallback(Boolean enableReadRequestsFallback)
enableEndpointDiscovery
is true
2. the Azure Cosmos DB account has more than one regionenableReadRequestsFallback
- flag to enable reads to go to multiple regions configured on an account of Azure Cosmos DB service.public List<String> preferredLocations()
public ConnectionPolicy preferredLocations(List<String> preferredLocations)
When EnableEndpointDiscovery is true and PreferredRegions is non-empty, the SDK will prefer to use the locations in the collection in the order they are specified to perform operations.
If EnableEndpointDiscovery is set to false, this property is ignored.
preferredLocations
- the list of preferred locations.public InetSocketAddress proxy()
public ConnectionPolicy proxy(String proxyHost, int proxyPort)
proxyHost
- The proxy server host.proxyPort
- The proxy server port.Copyright © 2019. All rights reserved.