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 |
GetDefault()
Gets the default connection policy.
|
boolean |
getEnableEndpointDiscovery()
Gets the flag to enable endpoint discovery for geo-replicated database accounts.
|
int |
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.
|
Integer |
getMaxRetryOnThrottledAttempts()
Deprecated.
|
MediaReadMode |
getMediaReadMode()
Gets the attachment content (aka media) download mode.
|
int |
getMediaRequestTimeout()
Gets or sets Time to wait for response from network peer for attachment
content (aka media) operations.
|
Collection<String> |
getPreferredLocations()
Gets the preferred locations for geo-replicated database accounts
|
org.apache.http.HttpHost |
getProxy()
Gets a proxy which will be used when making a request.
|
int |
getRequestTimeout()
Gets the request timeout (time to wait for response from network peer) in
seconds.
|
RetryOptions |
getRetryOptions()
Gets the retry policy options associated with the DocumentClient instance.
|
String |
getUserAgentSuffix()
Gets the value of user-agent suffix.
|
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.
|
void |
setIdleConnectionTimeout(int idleConnectionTimeout)
sets the value of the timeout for an idle connection.
|
void |
setMaxPoolSize(int maxPoolSize)
Sets the value of the connection pool size of the httpclient, the default
is 100.
|
void |
setMaxRetryOnThrottledAttempts(Integer maxRetryOnThrottledAttempts)
Deprecated.
|
void |
setMediaReadMode(MediaReadMode mediaReadMode)
Sets the attachment content (aka media) download mode.
|
void |
setMediaRequestTimeout(int mediaRequestTimeout)
Gets or sets Time to wait for response from network peer for attachment
content (aka media) operations.
|
void |
setPreferredLocations(Collection<String> preferredLocations)
Sets the preferred locations for geo-replicated database accounts.
|
void |
setProxy(org.apache.http.HttpHost proxy)
Sets a proxy which will be used when making a request.
|
void |
setRequestTimeout(int requestTimeout)
Sets the request timeout (time to wait for response from network peer) in
seconds.
|
void |
setRetryOptions(RetryOptions retryOptions)
Sets the retry policy options associated with the DocumentClient instance.
|
void |
setUserAgentSuffix(String userAgentSuffix)
sets the value of the user-agent suffix.
|
String |
toString() |
public static ConnectionPolicy GetDefault()
public int getRequestTimeout()
public void setRequestTimeout(int requestTimeout)
requestTimeout - the request timeout in seconds.public int getMediaRequestTimeout()
public void setMediaRequestTimeout(int mediaRequestTimeout)
mediaRequestTimeout - the media request timeout in seconds.public ConnectionMode getConnectionMode()
public void setConnectionMode(ConnectionMode connectionMode)
connectionMode - the connection mode.public MediaReadMode getMediaReadMode()
public void setMediaReadMode(MediaReadMode mediaReadMode)
mediaReadMode - the media read mode.public int getMaxPoolSize()
public void setMaxPoolSize(int maxPoolSize)
maxPoolSize - The value of the connection pool size the httpclient is using.public int getIdleConnectionTimeout()
public void setIdleConnectionTimeout(int idleConnectionTimeout)
idleConnectionTimeout - the timeout for an idle connection in seconds.public String getUserAgentSuffix()
public void setUserAgentSuffix(String userAgentSuffix)
userAgentSuffix - The value to be appended to the user-agent header, this is
used for monitoring purposes.@Deprecated public Integer getMaxRetryOnThrottledAttempts()
This property is deprecated. Please use connectionPolicy.getRetryOptions().getMaxRetryAttemptsOnThrottledRequests() for equivalent functionality.
@Deprecated public void setMaxRetryOnThrottledAttempts(Integer maxRetryOnThrottledAttempts)
When a client is sending request faster than the request rate limit imposed by the service, the service will return HttpStatusCode 429 (Too Many Request) to throttle the client. The current implementation in the SDK will then wait for the amount of time the service tells it to wait and retry after the time has elapsed.
The default value is 9. This means in the case where the request is throttled, the same request will be issued for a maximum of 10 times to the server before an error is returned to the application.
This property is deprecated. Please use connectionPolicy.getRetryOptions().setMaxRetryAttemptsOnThrottledRequests() for equivalent functionality.
maxRetryOnThrottledAttempts - the max number of retry attempts on failed requests.public RetryOptions getRetryOptions()
public void 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.public boolean getEnableEndpointDiscovery()
public void 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 Collection<String> getPreferredLocations()
public void setPreferredLocations(Collection<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 org.apache.http.HttpHost getProxy()
null.public void setProxy(org.apache.http.HttpHost proxy)
null.proxy - A proxy to use when making a request.Copyright © 2018. All rights reserved.