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 Details

    • logger

      protected Logger 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

      public boolean shouldRetryRequest(HttpCommand command, HttpResponse response)
      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 interface HttpRetryHandler
    • delayRequestUntilAllowed

      protected boolean delayRequestUntilAllowed(HttpCommand command, HttpResponse response)
    • getRetryCountLimit

      public int getRetryCountLimit()
    • getMaxRateLimitWait

      public int getMaxRateLimitWait()