ResponseT - response typepublic class ScheduledRetryingExecutor<ResponseT> extends Object implements RetryingExecutorWithContext<ResponseT>
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 and Description |
|---|
ScheduledRetryingExecutor(RetryAlgorithm<ResponseT> retryAlgorithm,
ScheduledExecutorService scheduler)
Creates a new scheduled retry executor, which will be using
scheduler for actual
attempts scheduling and retryAlgorithm for retrying strategy. |
| Modifier and Type | Method and Description |
|---|---|
RetryingFuture<ResponseT> |
createFuture(Callable<ResponseT> callable)
Creates a
RetryingFuture, which is a facade, returned to the client code to wait for
any retriable operation to complete. |
RetryingFuture<ResponseT> |
createFuture(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. |
com.google.api.core.ApiFuture<ResponseT> |
submit(RetryingFuture<ResponseT> retryingFuture)
Submits an attempt for execution in a different thread.
|
public ScheduledRetryingExecutor(RetryAlgorithm<ResponseT> retryAlgorithm, ScheduledExecutorService scheduler)
scheduler for actual
attempts scheduling and retryAlgorithm for retrying strategy.retryAlgorithm - retry algorithm to usescheduler - schedulerpublic RetryingFuture<ResponseT> createFuture(Callable<ResponseT> callable)
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.createFuture in interface RetryingExecutor<ResponseT>callable - the actual callable, which should be executed in a retriable context@BetaApi(value="The surface for passing per operation state is not yet stable") public RetryingFuture<ResponseT> createFuture(Callable<ResponseT> callable, RetryingContext context)
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.createFuture in interface RetryingExecutorWithContext<ResponseT>callable - the actual callable, which should be executed in a retriable contextcontext - the context for this operationpublic com.google.api.core.ApiFuture<ResponseT> submit(RetryingFuture<ResponseT> retryingFuture)
submit in interface RetryingExecutor<ResponseT>retryingFuture - the future previously returned by createFuture(Callable,
RetryingContext)