Package org.apache.http.impl.client
Class DefaultServiceUnavailableRetryStrategy
- java.lang.Object
-
- org.apache.http.impl.client.DefaultServiceUnavailableRetryStrategy
-
- All Implemented Interfaces:
ServiceUnavailableRetryStrategy
@Contract(threading=IMMUTABLE) public class DefaultServiceUnavailableRetryStrategy extends java.lang.Object implements ServiceUnavailableRetryStrategy
Default implementation of theServiceUnavailableRetryStrategyinterface. that retries503(Service Unavailable) responses for a fixed number of times at a fixed interval.- Since:
- 4.2
-
-
Field Summary
Fields Modifier and Type Field Description private intmaxRetriesMaximum number of allowed retries if the server responds with a HTTP code in our retry code list.private longretryIntervalRetry interval between subsequent requests, in milliseconds.
-
Constructor Summary
Constructors Constructor Description DefaultServiceUnavailableRetryStrategy()DefaultServiceUnavailableRetryStrategy(int maxRetries, int retryInterval)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetRetryInterval()booleanretryRequest(org.apache.http.HttpResponse response, int executionCount, org.apache.http.protocol.HttpContext context)Determines if a method should be retried given the response from the target server.
-
-
-
Field Detail
-
maxRetries
private final int maxRetries
Maximum number of allowed retries if the server responds with a HTTP code in our retry code list. Default value is 1.
-
retryInterval
private final long retryInterval
Retry interval between subsequent requests, in milliseconds. Default value is 1 second.
-
-
Method Detail
-
retryRequest
public boolean retryRequest(org.apache.http.HttpResponse response, int executionCount, org.apache.http.protocol.HttpContext context)Description copied from interface:ServiceUnavailableRetryStrategyDetermines if a method should be retried given the response from the target server.- Specified by:
retryRequestin interfaceServiceUnavailableRetryStrategy- Parameters:
response- the response from the target serverexecutionCount- the number of times this method has been unsuccessfully executedcontext- the context for the request execution- Returns:
trueif the method should be retried,falseotherwise
-
getRetryInterval
public long getRetryInterval()
- Specified by:
getRetryIntervalin interfaceServiceUnavailableRetryStrategy- Returns:
- The interval between the subsequent auto-retries.
-
-