Package com.google.api.gax.retrying
Class ScheduledRetryingExecutor<ResponseT>
- java.lang.Object
-
- com.google.api.gax.retrying.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 usesScheduledExecutorServiceto 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 theExecutorService.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 underlyingScheduledExecutorService.This class is thread-safe.
-
-
Constructor Summary
Constructors Constructor Description ScheduledRetryingExecutor(RetryAlgorithm<ResponseT> retryAlgorithm, java.util.concurrent.ScheduledExecutorService scheduler)Creates a new scheduled retry executor, which will be usingschedulerfor actual attempts scheduling andretryAlgorithmfor retrying strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RetryingFuture<ResponseT>createFuture(java.util.concurrent.Callable<ResponseT> callable)Creates aRetryingFuture, which is a facade, returned to the client code to wait for any retriable operation to complete.RetryingFuture<ResponseT>createFuture(java.util.concurrent.Callable<ResponseT> callable, RetryingContext context)Creates aRetryingFuture, 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.
-
-
-
Constructor Detail
-
ScheduledRetryingExecutor
public ScheduledRetryingExecutor(RetryAlgorithm<ResponseT> retryAlgorithm, java.util.concurrent.ScheduledExecutorService scheduler)
Creates a new scheduled retry executor, which will be usingschedulerfor actual attempts scheduling andretryAlgorithmfor retrying strategy.- Parameters:
retryAlgorithm- retry algorithm to usescheduler- scheduler
-
-
Method Detail
-
createFuture
public RetryingFuture<ResponseT> createFuture(java.util.concurrent.Callable<ResponseT> callable)
Creates aRetryingFuture, which is a facade, returned to the client code to wait for any retriable operation to complete. The returned future is bounded tothisexecutor instance.- Specified by:
createFuturein interfaceRetryingExecutor<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 aRetryingFuture, which is a facade, returned to the client code to wait for any retriable operation to complete. The returned future is bounded tothisexecutor instance.- Specified by:
createFuturein interfaceRetryingExecutorWithContext<ResponseT>- Parameters:
callable- the actual callable, which should be executed in a retriable contextcontext- the context for this operation- Returns:
- retrying future facade
-
submit
public com.google.api.core.ApiFuture<ResponseT> submit(RetryingFuture<ResponseT> retryingFuture)
Submits an attempt for execution in a different thread.- Specified by:
submitin interfaceRetryingExecutor<ResponseT>- Parameters:
retryingFuture- the future previously returned bycreateFuture(Callable, RetryingContext)- Returns:
- submitted attempt future
-
-