Package org.jclouds.http.handlers
Class BackoffLimitedRetryHandler
java.lang.Object
org.jclouds.http.handlers.BackoffLimitedRetryHandler
- All Implemented Interfaces:
HttpRetryHandler,IOExceptionRetryHandler
- Direct Known Subclasses:
AWSEC2IOExceptionRetryHandler,AWSServerErrorRetryHandler,AzureRetryableErrorHandler,B2RetryHandler,InvalidateSessionAndRetryOn401AndLogoutOnClose,SessionManager
@Singleton
public class BackoffLimitedRetryHandler
extends Object
implements HttpRetryHandler, IOExceptionRetryHandler
Allow replayable request to be retried a limited number of times, and impose an exponential
back-off delay before returning.
The back-off delay grows rapidly according to the formula
50 * (
. For example:
^ 2)invalid reference
TransformingHttpCommand#getFailureCount()
| Number of Attempts | Delay in milliseconds |
|---|---|
| 1 | 50 |
| 2 | 200 |
| 3 | 450 |
| 4 | 800 |
| 5 | 1250 |
This implementation has two side-effects. It increments the command's failure count with
, because this failure count value is used
to determine how many times the command has already been tried. It also closes the response's
content input stream to ensure connections are cleaned up.invalid reference
TransformingHttpCommand#incrementFailureCount()
-
Field Summary
FieldsFields inherited from interface org.jclouds.http.HttpRetryHandler
ALWAYS_RETRY, NEVER_RETRYFields inherited from interface org.jclouds.http.IOExceptionRetryHandler
ALWAYS_RETRY, NEVER_RETRY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidimposeBackoffExponentialDelay(int failureCount, String commandDescription) voidimposeBackoffExponentialDelay(long period, int pow, int failureCount, int max, String commandDescription) voidimposeBackoffExponentialDelay(long period, long maxPeriod, int pow, int failureCount, int max, String commandDescription) booleanshouldRetryRequest(HttpCommand command, IOException error) booleanshouldRetryRequest(HttpCommand command, HttpResponse response) Return true if the command should be retried.
-
Field Details
-
INSTANCE
-
logger
-
-
Constructor Details
-
BackoffLimitedRetryHandler
public BackoffLimitedRetryHandler()
-
-
Method Details
-
shouldRetryRequest
- Specified by:
shouldRetryRequestin interfaceIOExceptionRetryHandler
-
shouldRetryRequest
Description copied from interface:HttpRetryHandlerReturn true if the command should be retried. This method should only be invoked when the response has failed with a HTTP 5xx error indicating a server-side error.- Specified by:
shouldRetryRequestin interfaceHttpRetryHandler
-
imposeBackoffExponentialDelay
-
imposeBackoffExponentialDelay
public void imposeBackoffExponentialDelay(long period, int pow, int failureCount, int max, String commandDescription) -
imposeBackoffExponentialDelay
public void imposeBackoffExponentialDelay(long period, long maxPeriod, int pow, int failureCount, int max, String commandDescription)
-