ConnectionPolicy Class
- java.
lang. Object - com.
microsoft. azure. cosmosdb. ConnectionPolicy
- com.
public class ConnectionPolicy
Represents the Connection policy associated with a DocumentClient in the Azure Cosmos DB database service.
Constructor Summary
Constructor | Description |
---|---|
ConnectionPolicy() |
Constructor. |
Method Summary
Modifier and Type | Method and Description |
---|---|
Connection |
getConnectionMode()
Gets the connection mode used in the client. |
Connection |
GetDefault()
Gets the default connection policy. |
boolean |
getEnableEndpointDiscovery()
Gets the flag to enable endpoint discovery for geo-replicated database accounts. |
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. |
Media |
getMediaReadMode()
Gets the attachment content (aka media) download mode. |
int |
getMediaRequestTimeoutInMillis()
Gets or sets time to wait for response from network peer for attachment content (aka media) operations. |
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. |
Retry |
getRetryOptions()
Gets the retry policy options associated with the DocumentClient instance. |
String |
getUserAgentSuffix()
Gets the value of user-agent suffix. |
Boolean |
isEnableReadRequestsFallback()
Gets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service. 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 |
boolean |
isUsingMultipleWriteLocations()
Gets the flag to enable writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service. 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 directed to first region in PreferredLocations property if it's a write region or the primary account region if no PreferredLocations are specified. The value should match your account configuration. During the client lifetime, writes can change regional endpoint in the case of any event described at https://docs.microsoft.com/azure/cosmos-db/troubleshoot-sdk-availability |
void |
setConnectionMode(ConnectionMode connectionMode)
Sets the connection mode used in the client. |
void |
setEnableEndpointDiscovery(boolean enableEndpointDiscovery)
Sets the flag to enable endpoint discovery for geo-replicated database accounts. 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. |
void |
setEnableReadRequestsFallback(Boolean enableReadRequestsFallback)
Sets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service. 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 |
void |
setIdleConnectionTimeoutInMillis(int idleConnectionTimeoutInMillis)
sets the value of the timeout for an idle connection. After that time, the connection will be automatically closed. |
void |
setMaxPoolSize(int maxPoolSize)
Sets the value of the connection pool size, the default is 1000. |
void |
setMediaReadMode(MediaReadMode mediaReadMode)
Sets the attachment content (aka media) download mode. |
void |
setMediaRequestTimeoutInMillis(int mediaRequestTimeoutInMillis)
Gets or sets Time to wait for response from network peer for attachment content (aka media) operations. |
void |
setPreferredLocations(List<String> preferredLocations)
Sets the preferred locations for geo-replicated database accounts. For example, "East US" as the preferred location. 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. |
void |
setProxy(String proxyHost, int proxyPort)
This will create the InetSocketAddress for proxy server, all the requests to cosmoDB will route from this address. |
void |
setRequestTimeoutInMillis(int requestTimeoutInMillis)
Sets the request timeout (time to wait for response from network peer) in milliseconds. The default is 60 seconds. |
void |
setRetryOptions(RetryOptions retryOptions)
Sets the retry policy options associated with the DocumentClient instance. 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. |
void |
setUserAgentSuffix(String userAgentSuffix)
sets the value of the user-agent suffix. |
void |
setUsingMultipleWriteLocations(boolean usingMultipleWriteLocations)
Sets the flag to enable writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service. 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 directed to first region in PreferredLocations property if it's a write region or the primary account region if no PreferredLocations are specified. The value should match your account configuration. During the client lifetime, writes can change regional endpoint in the case of any event described at https://docs.microsoft.com/azure/cosmos-db/troubleshoot-sdk-availability |
String | toString() |
Constructor Details
ConnectionPolicy
public ConnectionPolicy()
Constructor.
Method Details
getConnectionMode
public ConnectionMode getConnectionMode()
Gets the connection mode used in the client.
Returns:
GetDefault
public static ConnectionPolicy GetDefault()
Gets the default connection policy.
Returns:
getEnableEndpointDiscovery
public boolean getEnableEndpointDiscovery()
Gets the flag to enable endpoint discovery for geo-replicated database accounts.
Returns:
getIdleConnectionTimeoutInMillis
public int getIdleConnectionTimeoutInMillis()
Gets the value of the timeout for an idle connection, the default is 60 seconds.
Returns:
getMaxPoolSize
public int getMaxPoolSize()
Gets the value of the connection pool size the client is using.
Returns:
getMediaReadMode
public MediaReadMode getMediaReadMode()
Gets the attachment content (aka media) download mode.
Returns:
getMediaRequestTimeoutInMillis
public int getMediaRequestTimeoutInMillis()
Gets or sets time to wait for response from network peer for attachment content (aka media) operations.
Returns:
getPreferredLocations
public List
Gets the preferred locations for geo-replicated database accounts
Returns:
getProxy
public InetSocketAddress getProxy()
Gets the InetSocketAddress of proxy server.
Returns:
getRequestTimeoutInMillis
public int getRequestTimeoutInMillis()
Gets the request timeout (time to wait for response from network peer) in milliseconds.
Returns:
getRetryOptions
public RetryOptions getRetryOptions()
Gets the retry policy options associated with the DocumentClient instance.
Returns:
getUserAgentSuffix
public String getUserAgentSuffix()
Gets the value of user-agent suffix.
Returns:
isEnableReadRequestsFallback
public Boolean isEnableReadRequestsFallback()
Gets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.
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
Returns:
isUsingMultipleWriteLocations
public boolean isUsingMultipleWriteLocations()
Gets the flag to enable writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.
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 directed to first region in PreferredLocations property if it's a write region or the primary account region if no PreferredLocations are specified.
The value should match your account configuration.
During the client lifetime, writes can change regional endpoint in the case of any event described at https://docs.microsoft.com/azure/cosmos-db/troubleshoot-sdk-availability
Returns:
setConnectionMode
public void setConnectionMode(ConnectionMode connectionMode)
Sets the connection mode used in the client.
Parameters:
setEnableEndpointDiscovery
public void setEnableEndpointDiscovery(boolean enableEndpointDiscovery)
Sets the flag to enable endpoint discovery for geo-replicated database accounts.
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.
Parameters:
setEnableReadRequestsFallback
public void setEnableReadRequestsFallback(Boolean enableReadRequestsFallback)
Sets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.
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
Parameters:
setIdleConnectionTimeoutInMillis
public void setIdleConnectionTimeoutInMillis(int idleConnectionTimeoutInMillis)
sets the value of the timeout for an idle connection. After that time, the connection will be automatically closed.
Parameters:
setMaxPoolSize
public void setMaxPoolSize(int maxPoolSize)
Sets the value of the connection pool size, the default is 1000.
Parameters:
setMediaReadMode
public void setMediaReadMode(MediaReadMode mediaReadMode)
Sets the attachment content (aka media) download mode.
Parameters:
setMediaRequestTimeoutInMillis
public void setMediaRequestTimeoutInMillis(int mediaRequestTimeoutInMillis)
Gets or sets Time to wait for response from network peer for attachment content (aka media) operations.
Parameters:
setPreferredLocations
public void setPreferredLocations(List
Sets the preferred locations for geo-replicated database accounts. For example, "East US" as the preferred location.
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.
Parameters:
setProxy
public void setProxy(String proxyHost, int proxyPort)
This will create the InetSocketAddress for proxy server, all the requests to cosmoDB will route from this address.
Parameters:
setRequestTimeoutInMillis
public void setRequestTimeoutInMillis(int requestTimeoutInMillis)
Sets the request timeout (time to wait for response from network peer) in milliseconds. The default is 60 seconds.
Parameters:
setRetryOptions
public void setRetryOptions(RetryOptions retryOptions)
Sets the retry policy options associated with the DocumentClient instance.
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.
Parameters:
setUserAgentSuffix
public void setUserAgentSuffix(String userAgentSuffix)
sets the value of the user-agent suffix.
Parameters:
setUsingMultipleWriteLocations
public void setUsingMultipleWriteLocations(boolean usingMultipleWriteLocations)
Sets the flag to enable writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.
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 directed to first region in PreferredLocations property if it's a write region or the primary account region if no PreferredLocations are specified.
The value should match your account configuration.
During the client lifetime, writes can change regional endpoint in the case of any event described at https://docs.microsoft.com/azure/cosmos-db/troubleshoot-sdk-availability
Parameters:
toString
public String toString()
Applies to
Azure SDK for Java