@Beta public class HttpBackOffUnsuccessfulResponseHandler extends Objectimplements HttpUnsuccessfulResponseHandler
Beta
BackOff.
It is designed to work with only one HttpRequest at a time. As a result you MUST create a new instance of HttpBackOffUnsuccessfulResponseHandler with a new instance of BackOff for each instance of HttpRequest.
Sample usage:
request.setUnsuccessfulResponseHandler(
new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()));
Note: Implementation doesn't call BackOff at all, since it expects a new BackOff instance.
Implementation is not thread-safe
| Modifier and Type | Class and Description |
|---|---|
static interface |
HttpBackOffUnsuccessfulResponseHandler
|
| Constructor and Description |
|---|
HttpBackOffUnsuccessfulResponseHandler(BackOff
Constructs a new instance from a
BackOff.
|
| Modifier and Type | Method and Description |
|---|---|
BackOff |
getBackOff()
Returns the back-off.
|
HttpBackOffUnsuccessfulResponseHandler |
getBackOffRequired()
Returns the
HttpBackOffUnsuccessfulResponseHandler.BackOffRequired instance which determines if back-off is required based on an abnormal HTTP response.
|
Sleeper |
getSleeper()
Returns the sleeper.
|
boolean |
handleResponse(HttpRequest
Handler that will be invoked when an abnormal response is received.
|
HttpBackOffUnsuccessfulResponseHandler |
setBackOffRequired(HttpBackOffUnsuccessfulResponseHandler
Sets the
HttpBackOffUnsuccessfulResponseHandler.BackOffRequired instance which determines if back-off is required based on an abnormal HTTP response.
|
HttpBackOffUnsuccessfulResponseHandler |
setSleeper(Sleeper
Sets the sleeper.
|
public final BackOffgetBackOff()
public final HttpBackOffUnsuccessfulResponseHandler.BackOffRequired getBackOffRequired()
HttpBackOffUnsuccessfulResponseHandler.BackOffRequired instance which determines if back-off is required based on an abnormal HTTP response.
public HttpBackOffUnsuccessfulResponseHandlersetBackOffRequired(HttpBackOffUnsuccessfulResponseHandler .BackOffRequired backOffRequired)
HttpBackOffUnsuccessfulResponseHandler.BackOffRequired instance which determines if back-off is required based on an abnormal HTTP response.
The default value is HttpBackOffUnsuccessfulResponseHandler.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public final SleepergetSleeper()
public HttpBackOffUnsuccessfulResponseHandlersetSleeper(Sleeper sleeper)
The default value is Sleeper.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public final boolean handleResponse(HttpRequestrequest, HttpResponse response, boolean supportsRetry) throws IOException
Handles the request with BackOff. That means that if back-off is required a call to Sleeper will be made.
handleResponse in interface
HttpUnsuccessfulResponseHandler
request - Request object that can be read from for context or modified before retry
response - Response to process
supportsRetry - Whether there will actually be a retry if this handler return
true. Some handlers may want to have an effect only when there will actually be a retry after they handle their event (e.g. a handler that implements exponential backoff).
IOException