Class DefaultHttpRequestRetryStrategy

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        DefaultHttpRequestRetryStrategy()
      Create the HTTP request retry strategy with a max retry count of 1, default retry interval of 1 second, and using the following list of non-retriable I/O exception classes:
      InterruptedIOException UnknownHostException ConnectException ConnectionClosedException SSLException and retriable HTTP status codes:
      SC_TOO_MANY_REQUESTS (429) SC_SERVICE_UNAVAILABLE (503)
        DefaultHttpRequestRetryStrategy​(int maxRetries, org.apache.hc.core5.util.TimeValue defaultRetryInterval)
      Create the HTTP request retry strategy using the following list of non-retriable I/O exception classes:
      InterruptedIOException UnknownHostException ConnectException ConnectionClosedException NoRouteToHostException SSLException and retriable HTTP status codes:
      SC_TOO_MANY_REQUESTS (429) SC_SERVICE_UNAVAILABLE (503)
      protected DefaultHttpRequestRetryStrategy​(int maxRetries, org.apache.hc.core5.util.TimeValue defaultRetryInterval, java.util.Collection<java.lang.Class<? extends java.io.IOException>> clazzes, java.util.Collection<java.lang.Integer> codes)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.hc.core5.util.TimeValue getRetryInterval​(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context)
      Determines the retry interval between subsequent retries.
      protected boolean handleAsIdempotent​(org.apache.hc.core5.http.HttpRequest request)  
      boolean retryRequest​(org.apache.hc.core5.http.HttpRequest request, java.io.IOException exception, int execCount, org.apache.hc.core5.http.protocol.HttpContext context)
      Determines if a method should be retried after an I/O exception occurred during execution.
      boolean retryRequest​(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context)
      Determines if a method should be retried given the response from the target server.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • maxRetries

        private final int maxRetries
        Maximum number of allowed retries
      • defaultRetryInterval

        private final org.apache.hc.core5.util.TimeValue defaultRetryInterval
        Retry interval between subsequent retries
      • nonRetriableIOExceptionClasses

        private final java.util.Set<java.lang.Class<? extends java.io.IOException>> nonRetriableIOExceptionClasses
        Derived IOExceptions which shall not be retried
      • retriableCodes

        private final java.util.Set<java.lang.Integer> retriableCodes
        HTTP status codes which shall be retried
    • Constructor Detail

      • DefaultHttpRequestRetryStrategy

        protected DefaultHttpRequestRetryStrategy​(int maxRetries,
                                                  org.apache.hc.core5.util.TimeValue defaultRetryInterval,
                                                  java.util.Collection<java.lang.Class<? extends java.io.IOException>> clazzes,
                                                  java.util.Collection<java.lang.Integer> codes)
      • DefaultHttpRequestRetryStrategy

        public DefaultHttpRequestRetryStrategy​(int maxRetries,
                                               org.apache.hc.core5.util.TimeValue defaultRetryInterval)
        Create the HTTP request retry strategy using the following list of non-retriable I/O exception classes:
        • InterruptedIOException
        • UnknownHostException
        • ConnectException
        • ConnectionClosedException
        • NoRouteToHostException
        • SSLException
        and retriable HTTP status codes:
        • SC_TOO_MANY_REQUESTS (429)
        • SC_SERVICE_UNAVAILABLE (503)
        Parameters:
        maxRetries - how many times to retry; 0 means no retries
        defaultRetryInterval - the default retry interval between subsequent retries if the Retry-After header is not set or invalid.
      • DefaultHttpRequestRetryStrategy

        public DefaultHttpRequestRetryStrategy()
        Create the HTTP request retry strategy with a max retry count of 1, default retry interval of 1 second, and using the following list of non-retriable I/O exception classes:
        • InterruptedIOException
        • UnknownHostException
        • ConnectException
        • ConnectionClosedException
        • SSLException
        and retriable HTTP status codes:
        • SC_TOO_MANY_REQUESTS (429)
        • SC_SERVICE_UNAVAILABLE (503)
    • Method Detail

      • retryRequest

        public boolean retryRequest​(org.apache.hc.core5.http.HttpRequest request,
                                    java.io.IOException exception,
                                    int execCount,
                                    org.apache.hc.core5.http.protocol.HttpContext context)
        Description copied from interface: HttpRequestRetryStrategy
        Determines if a method should be retried after an I/O exception occurred during execution.
        Specified by:
        retryRequest in interface HttpRequestRetryStrategy
        Parameters:
        request - the request failed due to an I/O exception
        exception - the exception that occurred
        execCount - the number of times this method has been unsuccessfully executed
        context - the context for the request execution
        Returns:
        true if the request should be retried, false otherwise
      • retryRequest

        public boolean retryRequest​(org.apache.hc.core5.http.HttpResponse response,
                                    int execCount,
                                    org.apache.hc.core5.http.protocol.HttpContext context)
        Description copied from interface: HttpRequestRetryStrategy
        Determines if a method should be retried given the response from the target server.
        Specified by:
        retryRequest in interface HttpRequestRetryStrategy
        Parameters:
        response - the response from the target server
        execCount - the number of times this method has been unsuccessfully executed
        context - the context for the request execution
        Returns:
        true if the request should be retried, false otherwise
      • getRetryInterval

        public org.apache.hc.core5.util.TimeValue getRetryInterval​(org.apache.hc.core5.http.HttpResponse response,
                                                                   int execCount,
                                                                   org.apache.hc.core5.http.protocol.HttpContext context)
        Description copied from interface: HttpRequestRetryStrategy
        Determines the retry interval between subsequent retries.
        Specified by:
        getRetryInterval in interface HttpRequestRetryStrategy
        Parameters:
        response - the response from the target server
        execCount - the number of times this method has been unsuccessfully executed
        context - the context for the request execution
        Returns:
        the retry interval between subsequent retries
      • handleAsIdempotent

        protected boolean handleAsIdempotent​(org.apache.hc.core5.http.HttpRequest request)