@Singleton public class BackoffLimitedRetryHandler extends Object implements HttpRetryHandler, IOExceptionRetryHandler
The back-off delay grows rapidly according to the formula
50 * (
. For example:
TransformingHttpCommand#getFailureCount()
^ 2)
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
TransformingHttpCommand#incrementFailureCount()
, 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.
Modifier and Type | Field and Description |
---|---|
static BackoffLimitedRetryHandler |
INSTANCE |
protected Logger |
logger |
ALWAYS_RETRY, NEVER_RETRY
ALWAYS_RETRY, NEVER_RETRY
Constructor and Description |
---|
BackoffLimitedRetryHandler() |
Modifier and Type | Method and Description |
---|---|
void |
imposeBackoffExponentialDelay(int failureCount,
String commandDescription) |
void |
imposeBackoffExponentialDelay(long period,
int pow,
int failureCount,
int max,
String commandDescription) |
void |
imposeBackoffExponentialDelay(long period,
long maxPeriod,
int pow,
int failureCount,
int max,
String commandDescription) |
boolean |
shouldRetryRequest(HttpCommand command,
HttpResponse response)
Return true if the command should be retried.
|
boolean |
shouldRetryRequest(HttpCommand command,
IOException error) |
public static final BackoffLimitedRetryHandler INSTANCE
protected Logger logger
public boolean shouldRetryRequest(HttpCommand command, IOException error)
shouldRetryRequest
in interface IOExceptionRetryHandler
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response)
HttpRetryHandler
shouldRetryRequest
in interface HttpRetryHandler
public void imposeBackoffExponentialDelay(int failureCount, String commandDescription)
public void imposeBackoffExponentialDelay(long period, int pow, int failureCount, int max, String commandDescription)
public void imposeBackoffExponentialDelay(long period, long maxPeriod, int pow, int failureCount, int max, String commandDescription)
Copyright © 2009-2013 jclouds. All Rights Reserved.