public final class ConnectionPolicy extends Object
Constructor and Description |
---|
ConnectionPolicy()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ConnectionMode |
getConnectionMode()
Gets the connection mode used in the client.
|
static ConnectionPolicy |
getDefaultPolicy()
Gets the default connection policy.
|
boolean |
getEnableEndpointDiscovery()
Gets the flag to enable endpoint discovery for geo-replicated database accounts.
|
Boolean |
getEnableReadRequestsFallback()
Gets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.
|
int |
getIdleConnectionTimeoutInMillis()
Gets the value of the timeout for an idle connection, the default is 60
seconds.
|
int |
getMaxPoolSize()
Gets the value of the connection pool size the client is using.
|
List<String> |
getPreferredLocations()
Gets the preferred locations for geo-replicated database accounts
|
InetSocketAddress |
getProxy()
Gets the InetSocketAddress of proxy server.
|
int |
getRequestTimeoutInMillis()
Gets the request timeout (time to wait for response from network peer) in
milliseconds.
|
RetryOptions |
getRetryOptions()
Gets the retry policy options associated with the DocumentClient instance.
|
String |
getUserAgentSuffix()
Gets the value of user-agent suffix.
|
boolean |
getUsingMultipleWriteLocations()
Gets the flag to enable writes on any locations (regions) for geo-replicated database accounts in the Azure
Cosmos DB service.
|
ConnectionPolicy |
setConnectionMode(ConnectionMode connectionMode)
Sets the connection mode used in the client.
|
ConnectionPolicy |
setEnableEndpointDiscovery(boolean enableEndpointDiscovery)
Sets the flag to enable endpoint discovery for geo-replicated database accounts.
|
ConnectionPolicy |
setEnableReadRequestsFallback(Boolean enableReadRequestsFallback)
Sets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.
|
ConnectionPolicy |
setIdleConnectionTimeoutInMillis(int idleConnectionTimeoutInMillis)
sets the value of the timeout for an idle connection.
|
ConnectionPolicy |
setMaxPoolSize(int maxPoolSize)
Sets the value of the connection pool size, the default
is 1000.
|
ConnectionPolicy |
setPreferredLocations(List<String> preferredLocations)
Sets the preferred locations for geo-replicated database accounts.
|
ConnectionPolicy |
setProxy(String proxyHost,
int proxyPort)
This will create the InetSocketAddress for proxy server,
all the requests to cosmoDB will route from this address.
|
ConnectionPolicy |
setRequestTimeoutInMillis(int requestTimeoutInMillis)
Sets the request timeout (time to wait for response from network peer) in
milliseconds.
|
ConnectionPolicy |
setRetryOptions(RetryOptions retryOptions)
Sets the retry policy options associated with the DocumentClient instance.
|
ConnectionPolicy |
setUserAgentSuffix(String userAgentSuffix)
sets the value of the user-agent suffix.
|
ConnectionPolicy |
setUsingMultipleWriteLocations(boolean usingMultipleWriteLocations)
Sets the flag to enable writes on any locations (regions) for geo-replicated database accounts in the Azure
Cosmos DB service.
|
String |
toString() |
public static ConnectionPolicy getDefaultPolicy()
public int getRequestTimeoutInMillis()
public ConnectionPolicy setRequestTimeoutInMillis(int requestTimeoutInMillis)
requestTimeoutInMillis
- the request timeout in milliseconds.public ConnectionMode getConnectionMode()
public ConnectionPolicy setConnectionMode(ConnectionMode connectionMode)
connectionMode
- the connection mode.public int getMaxPoolSize()
public ConnectionPolicy setMaxPoolSize(int maxPoolSize)
maxPoolSize
- The value of the connection pool size.public int getIdleConnectionTimeoutInMillis()
public ConnectionPolicy setIdleConnectionTimeoutInMillis(int idleConnectionTimeoutInMillis)
idleConnectionTimeoutInMillis
- the timeout for an idle connection in seconds.public String getUserAgentSuffix()
public ConnectionPolicy setUserAgentSuffix(String userAgentSuffix)
userAgentSuffix
- The value to be appended to the user-agent header, this is
used for monitoring purposes.public RetryOptions getRetryOptions()
public ConnectionPolicy setRetryOptions(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.IllegalArgumentException
- thrown if an error occurspublic boolean getEnableEndpointDiscovery()
public ConnectionPolicy setEnableEndpointDiscovery(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 getUsingMultipleWriteLocations()
When the value of this property is true, the SDK will direct write operations to available writable locations of geo-replicated database account. Writable locations are ordered by PreferredLocations property. Setting the property value to true has no effect until EnableMultipleWriteLocations in DatabaseAccount is also set to true.
DEFAULT value is true indicating that writes are directed to available writable locations of geo-replicated database account.
public Boolean getEnableReadRequestsFallback()
DEFAULT value is null.
If this property is not set, the default is true for all Consistency Levels other than Bounded Staleness,
The default is false for Bounded Staleness.
1. enableEndpointDiscovery
is true
2. the Azure Cosmos DB account has more than one region
public ConnectionPolicy setUsingMultipleWriteLocations(boolean usingMultipleWriteLocations)
When the value of this property is true, the SDK will direct write operations to available writable locations of geo-replicated database account. Writable locations are ordered by PreferredLocations property. Setting the property value to true has no effect until EnableMultipleWriteLocations in DatabaseAccount is also set to true.
DEFAULT value is false indicating that writes are only directed to first region in PreferredLocations property.
usingMultipleWriteLocations
- flag to enable writes on any locations (regions) for geo-replicated
database accounts.public ConnectionPolicy setEnableReadRequestsFallback(Boolean enableReadRequestsFallback)
DEFAULT value is null.
If this property is not set, the default is true for all Consistency Levels other than Bounded Staleness,
The default is false for Bounded Staleness.
1. enableEndpointDiscovery
is true
2. the Azure Cosmos DB account has more than one region
enableReadRequestsFallback
- flag to enable reads to go to multiple regions configured on an account of
Azure Cosmos DB service.public List<String> getPreferredLocations()
public ConnectionPolicy setPreferredLocations(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 getProxy()
public ConnectionPolicy setProxy(String proxyHost, int proxyPort)
proxyHost
- The proxy server host.proxyPort
- The proxy server port.Copyright © 2020 Microsoft Corporation. All rights reserved.