Class ScheduledRetryingExecutor<ResponseT>

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

    public class ScheduledRetryingExecutor<ResponseT>
    extends java.lang.Object
    implements RetryingExecutorWithContext<ResponseT>
    The retry executor which uses ScheduledExecutorService to schedule an attempt tasks.

    This implementation does not manage the lifecycle of the underlying ScheduledExecutorService, so it should be managed outside of this class (like calling the ExecutorService.shutdown() when the pool is not needed anymore). In a typical usage pattern there are usually multiple instances of this class sharing same instance of the underlying ScheduledExecutorService.

    This class is thread-safe.

    • Constructor Detail

      • ScheduledRetryingExecutor

        public ScheduledRetryingExecutor​(RetryAlgorithm<ResponseT> retryAlgorithm,
                                         java.util.concurrent.ScheduledExecutorService scheduler)
        Creates a new scheduled retry executor, which will be using scheduler for actual attempts scheduling and retryAlgorithm for retrying strategy.
        Parameters:
        retryAlgorithm - retry algorithm to use
        scheduler - scheduler
    • 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 returned 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
      • createFuture

        @BetaApi("The surface for passing per operation state is not yet stable")
        public RetryingFuture<ResponseT> createFuture​(java.util.concurrent.Callable<ResponseT> callable,
                                                      RetryingContext context)
        Creates a RetryingFuture, which is a facade, returned to the client code to wait for any retriable operation to complete. The returned future is bounded to this executor instance.
        Specified by:
        createFuture in interface RetryingExecutorWithContext<ResponseT>
        Parameters:
        callable - the actual callable, which should be executed in a retriable context
        context - the context for this operation
        Returns:
        retrying future facade