public class ExponentialRetryStrategy extends Object implements RetryStrategy
| Modifier and Type | Field and Description |
|---|---|
protected long |
initialDelayMillis
The delay to apply to the initial retry.
|
protected long |
initialThrottlingDelayMillis
The delay to apply to the initial retry if the last attempt was throttled.
|
protected long |
maxDelayMillis
The maximum delay to apply to a non-throttled retry
|
protected int |
maxRetries
The maximum number of retry attempts.
|
protected long |
maxThrottlingDelayMillis
The maximum delay to apply when retrying a throttled request.
|
| Constructor and Description |
|---|
ExponentialRetryStrategy(int maxRetries,
long initialDelayMillis)
Instantiate Exponential backoff retry strategy with the same delay for throttled and non-throttled retries
and no maximum delay for throttled or non-throttled retries.
|
ExponentialRetryStrategy(int maxRetries,
long initialDelayMillis,
long initialThrottlingDelayMillis)
Instantiate Exponential backoff retry strategy with no maximum delay for throttled or non-throttled retries.
|
ExponentialRetryStrategy(int maxRetries,
long initialDelayMillis,
long initialThrottlingDelayMillis,
long maxDelayMillis,
long maxThrottlingDelayMillis)
Instantiate Exponential backoff retry strategy
|
| Modifier and Type | Method and Description |
|---|---|
int |
getMaxRetries()
Get the maximum retry attempts
|
long |
getWaitTime(int retryCount,
int statusCode)
Return how long to wait until the next request
|
boolean |
isThrottledResponse(int statusCode)
Determine if a response indicates a throttled request
|
void |
setMaxRetries(int maxRetries)
Set the maximum retry attempts.
|
protected final long initialDelayMillis
protected final long initialThrottlingDelayMillis
protected final long maxDelayMillis
protected final long maxThrottlingDelayMillis
protected int maxRetries
public ExponentialRetryStrategy(int maxRetries,
long initialDelayMillis)
maxRetries - The maximum number of retriesinitialDelayMillis - The delay constant to apply to all retriespublic ExponentialRetryStrategy(int maxRetries,
long initialDelayMillis,
long initialThrottlingDelayMillis)
maxRetries - The maximum number of retriesinitialDelayMillis - The delay constant to apply to non-throttled retriesinitialThrottlingDelayMillis - The delay constant to apply to throttled retriespublic ExponentialRetryStrategy(int maxRetries,
long initialDelayMillis,
long initialThrottlingDelayMillis,
long maxDelayMillis,
long maxThrottlingDelayMillis)
maxRetries - The maximum number of retriesinitialDelayMillis - The delay constant to apply to non-throttled retriesinitialThrottlingDelayMillis - The delay constant to apply to throttled retriesmaxDelayMillis - The maximum delay to apply to a non-throttled retrymaxThrottlingDelayMillis - The maximum delay to apply when retrying a throttled request.public long getWaitTime(int retryCount,
int statusCode)
RetryStrategygetWaitTime in interface RetryStrategyretryCount - The number of retries that have been attemptedstatusCode - The status code returned by the last attemptpublic void setMaxRetries(int maxRetries)
RetryStrategysetMaxRetries in interface RetryStrategymaxRetries - The number of times to retry a failed requestpublic int getMaxRetries()
RetryStrategygetMaxRetries in interface RetryStrategypublic boolean isThrottledResponse(int statusCode)
statusCode - The status code returned by the last requestCopyright © 2024. All rights reserved.