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.
|
Duration |
getIdleConnectionTimeout()
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.
|
Duration |
getRequestTimeout()
Gets the request timeout (time to wait for response from network peer).
|
ThrottlingRetryOptions |
getThrottlingRetryOptions()
Gets the retry policy options associated with the DocumentClient instance.
|
String |
getUserAgentSuffix()
Gets the value of user-agent suffix.
|
boolean |
isEndpointDiscoveryEnabled()
Gets the flag to enable endpoint discovery for geo-replicated database accounts.
|
Boolean |
isReadRequestsFallbackEnabled()
Gets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.
|
boolean |
isUsingMultipleWriteLocations()
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 |
setEndpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)
Sets the flag to enable endpoint discovery for geo-replicated database accounts.
|
ConnectionPolicy |
setIdleConnectionTimeout(Duration idleConnectionTimeout)
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(InetSocketAddress proxy)
This will create the InetSocketAddress for proxy server,
all the requests to cosmoDB will route from this address.
|
ConnectionPolicy |
setReadRequestsFallbackEnabled(Boolean readRequestsFallbackEnabled)
Sets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.
|
ConnectionPolicy |
setRequestTimeout(Duration requestTimeout)
Sets the request timeout (time to wait for response from network peer).
|
ConnectionPolicy |
setThrottlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)
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 Duration getRequestTimeout()
public ConnectionPolicy setRequestTimeout(Duration requestTimeout)
requestTimeout
- the request timeout duration.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 Duration getIdleConnectionTimeout()
public ConnectionPolicy setIdleConnectionTimeout(Duration idleConnectionTimeout)
idleConnectionTimeout
- the duration for an idle connection.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 ThrottlingRetryOptions getThrottlingRetryOptions()
public ConnectionPolicy setThrottlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)
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.
throttlingRetryOptions
- the RetryOptions instance.IllegalArgumentException
- thrown if an error occurspublic boolean isEndpointDiscoveryEnabled()
public ConnectionPolicy setEndpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)
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.
endpointDiscoveryEnabled
- true if EndpointDiscovery is enabled.public boolean isUsingMultipleWriteLocations()
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 isReadRequestsFallbackEnabled()
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. ConnectionPolicy.endpointDiscoveryEnabled
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 setReadRequestsFallbackEnabled(Boolean readRequestsFallbackEnabled)
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. ConnectionPolicy.endpointDiscoveryEnabled
is true
2. the Azure Cosmos DB account has more than one region
readRequestsFallbackEnabled
- 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(InetSocketAddress proxy)
proxy
- The proxy server.Copyright © 2020 Microsoft Corporation. All rights reserved.