Package org.jclouds.http.handlers
Class RateLimitRetryHandler
java.lang.Object
org.jclouds.http.handlers.RateLimitRetryHandler
- All Implemented Interfaces:
HttpRetryHandler
- Direct Known Subclasses:
AzureRateLimitRetryHandler
,DigitalOcean2RateLimitRetryHandler
Retry handler that takes into account the provider rate limit and delays the
requests until they are known to succeed.
-
Field Summary
FieldsFields inherited from interface org.jclouds.http.HttpRetryHandler
ALWAYS_RETRY, NEVER_RETRY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
delayRequestUntilAllowed
(HttpCommand command, HttpResponse response) int
int
protected abstract com.google.common.base.Optional
<Long> millisToNextAvailableRequest
(HttpCommand command, HttpResponse response) Compute the number of milliseconds that must pass until a request can be performed.protected int
Returns the response status that will be considered a rate limit error.boolean
shouldRetryRequest
(HttpCommand command, HttpResponse response) Return true if the command should be retried.
-
Field Details
-
logger
-
-
Constructor Details
-
RateLimitRetryHandler
public RateLimitRetryHandler()
-
-
Method Details
-
rateLimitErrorStatus
protected int rateLimitErrorStatus()Returns the response status that will be considered a rate limit error.Providers can override this to customize which responses are retried.
-
millisToNextAvailableRequest
protected abstract com.google.common.base.Optional<Long> millisToNextAvailableRequest(HttpCommand command, HttpResponse response) Compute the number of milliseconds that must pass until a request can be performed.- Parameters:
command
- The command being executed.response
- The rate-limit error response.- Returns:
- The number of milliseconds to wait for an available request, if taht information is available.
-
shouldRetryRequest
Description copied from interface:HttpRetryHandler
Return 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:
shouldRetryRequest
in interfaceHttpRetryHandler
-
delayRequestUntilAllowed
-
getRetryCountLimit
public int getRetryCountLimit() -
getMaxRateLimitWait
public int getMaxRateLimitWait()
-