@Immutable public final class RetryPolicy extends Object
ClientConfiguration
. This class is immutable, therefore safe to be
shared by multiple clients.ClientConfiguration
,
PredefinedRetryPolicies
Modifier and Type | Class and Description |
---|---|
static interface |
RetryPolicy.BackoffStrategy
The hook for providing custom back-off strategy to control the sleep time
between retries.
|
static interface |
RetryPolicy.RetryCondition
The hook for providing custom condition on whether a failed request
should be retried.
|
static class |
RetryPolicy.RetryPolicyBuilder |
Constructor and Description |
---|
RetryPolicy(RetryPolicy.RetryCondition retryCondition,
RetryPolicy.BackoffStrategy backoffStrategy,
int maxErrorRetry,
boolean honorMaxErrorRetryInClientConfig)
Constructs a new retry policy.
|
RetryPolicy(RetryPolicy.RetryCondition retryCondition,
RetryPolicy.BackoffStrategy backoffStrategy,
int maxErrorRetry,
boolean honorMaxErrorRetryInClientConfig,
boolean honorDefaultMaxErrorRetryInRetryMode,
boolean honorBackoffStrategyInRetryMode) |
RetryPolicy(RetryPolicy.RetryCondition retryCondition,
RetryPolicy.BackoffStrategy backoffStrategy,
int maxErrorRetry,
boolean honorMaxErrorRetryInClientConfig,
RetryMode retryMode) |
Modifier and Type | Method and Description |
---|---|
static RetryPolicy.RetryPolicyBuilder |
builder() |
RetryPolicy.BackoffStrategy |
getBackoffStrategy()
Returns the back-off strategy included in this retry policy.
|
int |
getMaxErrorRetry()
Returns the maximum number of retry attempts.
|
RetryPolicy.RetryCondition |
getRetryCondition()
Returns the retry condition included in this retry policy.
|
RetryMode |
getRetryMode()
Returns the
RetryMode to be used. |
boolean |
isFastFailRateLimiting()
Whether the client should fail immediately when
RetryMode.ADAPTIVE is enabled, and there is not enough
capacity in the rate limiter to execute the request immediately. |
boolean |
isMaxErrorRetryInClientConfigHonored()
Returns whether this retry policy should honor the max error retry set in
ClientConfiguration.
|
public RetryPolicy(RetryPolicy.RetryCondition retryCondition, RetryPolicy.BackoffStrategy backoffStrategy, int maxErrorRetry, boolean honorMaxErrorRetryInClientConfig)
PredefinedRetryPolicies
for
some pre-defined policy components, and also the default policies used by
SDK.retryCondition
- Retry condition on whether a specific request and exception
should be retried. If null value is specified, the SDK'
default retry condition is used.backoffStrategy
- Back-off strategy for controlling how long the next retry
should wait. If null value is specified, the SDK' default
exponential back-off strategy is used.maxErrorRetry
- Maximum number of retry attempts for failed requests.honorMaxErrorRetryInClientConfig
- Whether this retry policy should honor the max error retry set
by ClientConfiguration.setMaxErrorRetry(int)
ClientConfiguration
,
PredefinedRetryPolicies
public RetryPolicy(RetryPolicy.RetryCondition retryCondition, RetryPolicy.BackoffStrategy backoffStrategy, int maxErrorRetry, boolean honorMaxErrorRetryInClientConfig, boolean honorDefaultMaxErrorRetryInRetryMode, boolean honorBackoffStrategyInRetryMode)
public RetryPolicy(RetryPolicy.RetryCondition retryCondition, RetryPolicy.BackoffStrategy backoffStrategy, int maxErrorRetry, boolean honorMaxErrorRetryInClientConfig, RetryMode retryMode)
public RetryPolicy.RetryCondition getRetryCondition()
public RetryPolicy.BackoffStrategy getBackoffStrategy()
public int getMaxErrorRetry()
public boolean isMaxErrorRetryInClientConfigHonored()
ClientConfiguration.setMaxErrorRetry(int)
public boolean isFastFailRateLimiting()
RetryMode.ADAPTIVE
is enabled, and there is not enough
capacity in the rate limiter to execute the request immediately.
The default configuration value is false
, which will cause client to wait until enough capacity is
available.
public static RetryPolicy.RetryPolicyBuilder builder()