Class DirectRetryingExecutor<ResponseT>

  • Type Parameters:
    ResponseT - response type
    All Implemented Interfaces:
    RetryingExecutor<ResponseT>, RetryingExecutorWithContext<ResponseT>

    public class DirectRetryingExecutor<ResponseT>
    extends java.lang.Object
    implements RetryingExecutorWithContext<ResponseT>
    The retry executor which executes attempts in the current thread, potentially causing the current thread to sleep for the specified amount of time before execution.

    This class is thread-safe.

    • Constructor Detail

      • DirectRetryingExecutor

        public DirectRetryingExecutor​(RetryAlgorithm<ResponseT> retryAlgorithm)
        Creates a new direct retrying executor instance, which will be using retryAlgorithm to determine retrying strategy.
        Parameters:
        retryAlgorithm - retry algorithm to use for attempts execution
        Throws:
        java.lang.NullPointerException - if retryAlgorithm is null
    • Method Detail

      • createFuture

        public RetryingFuture<ResponseT> createFuture​(java.util.concurrent.Callable<ResponseT> callable)
        Creates a RetryingFuture, which is a facade, returned to the client code to wait for any retriable operation to complete. The future is bounded to this executor instance.
        Specified by:
        createFuture in interface RetryingExecutor<ResponseT>
        Parameters:
        callable - the actual callable, which should be executed in a retriable context
        Returns:
        retrying future facade
      • sleep

        protected void sleep​(org.threeten.bp.Duration delay)
                      throws java.lang.InterruptedException
        This method simply calls Thread.sleep(long).
        Parameters:
        delay - time to sleep
        Throws:
        java.lang.InterruptedException - if any thread has interrupted the current thread