Package org.jclouds.http.handlers
Class RateLimitRetryHandler
- java.lang.Object
-
- org.jclouds.http.handlers.RateLimitRetryHandler
-
- All Implemented Interfaces:
HttpRetryHandler
- Direct Known Subclasses:
AzureRateLimitRetryHandler,DigitalOcean2RateLimitRetryHandler
@Beta public abstract class RateLimitRetryHandler extends Object implements HttpRetryHandler
Retry handler that takes into account the provider rate limit and delays the requests until they are known to succeed.
-
-
Field Summary
Fields Modifier and Type Field Description protected Loggerlogger-
Fields inherited from interface org.jclouds.http.HttpRetryHandler
ALWAYS_RETRY, NEVER_RETRY
-
-
Constructor Summary
Constructors Constructor Description RateLimitRetryHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleandelayRequestUntilAllowed(HttpCommand command, HttpResponse response)intgetMaxRateLimitWait()intgetRetryCountLimit()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 intrateLimitErrorStatus()Returns the response status that will be considered a rate limit error.booleanshouldRetryRequest(HttpCommand command, HttpResponse response)Return true if the command should be retried.
-
-
-
Field Detail
-
logger
protected Logger logger
-
-
Method Detail
-
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
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response)
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
-
delayRequestUntilAllowed
protected boolean delayRequestUntilAllowed(HttpCommand command, HttpResponse response)
-
getRetryCountLimit
public int getRetryCountLimit()
-
getMaxRateLimitWait
public int getMaxRateLimitWait()
-
-