Package com.google.api.gax.retrying
Class DirectRetryingExecutor<ResponseT>
- java.lang.Object
-
- com.google.api.gax.retrying.DirectRetryingExecutor<ResponseT>
-
- Type Parameters:
ResponseT
- response type
- All Implemented Interfaces:
RetryingExecutor<ResponseT>
,RetryingExecutorWithContext<ResponseT>
public class DirectRetryingExecutor<ResponseT> extends 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 Summary
Constructors Constructor Description DirectRetryingExecutor(RetryAlgorithm<ResponseT> retryAlgorithm)
Creates a new direct retrying executor instance, which will be usingretryAlgorithm
to determine retrying strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RetryingFuture<ResponseT>
createFuture(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(Callable<ResponseT> callable, RetryingContext context)
Creates aRetryingFuture
, which is a facade, returned to the client code to wait for any retriable operation to complete.protected void
sleep(org.threeten.bp.Duration delay)
This method simply callsThread.sleep(long)
.com.google.api.core.ApiFuture<ResponseT>
submit(RetryingFuture<ResponseT> retryingFuture)
Submits an attempt for execution in the current thread, causing the current thread to sleep for the specified by theRetryingFuture.getAttemptSettings()
amount of time.
-
-
-
Constructor Detail
-
DirectRetryingExecutor
public DirectRetryingExecutor(RetryAlgorithm<ResponseT> retryAlgorithm)
Creates a new direct retrying executor instance, which will be usingretryAlgorithm
to determine retrying strategy.- Parameters:
retryAlgorithm
- retry algorithm to use for attempts execution- Throws:
NullPointerException
- ifretryAlgorithm
is null
-
-
Method Detail
-
createFuture
public RetryingFuture<ResponseT> createFuture(Callable<ResponseT> callable)
Creates aRetryingFuture
, which is a facade, returned to the client code to wait for any retriable operation to complete. The future is bounded tothis
executor instance.- Specified by:
createFuture
in interfaceRetryingExecutor<ResponseT>
- Parameters:
callable
- the actual callable, which should be executed in a retriable context- Returns:
- retrying future facade
-
createFuture
public RetryingFuture<ResponseT> createFuture(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 future is bounded tothis
executor instance.- Specified by:
createFuture
in interfaceRetryingExecutorWithContext<ResponseT>
- Parameters:
callable
- the actual callable, which should be executed in a retriable context- Returns:
- retrying future facade
-
submit
public com.google.api.core.ApiFuture<ResponseT> submit(RetryingFuture<ResponseT> retryingFuture)
Submits an attempt for execution in the current thread, causing the current thread to sleep for the specified by theRetryingFuture.getAttemptSettings()
amount of time. As result, this method completes execution only after the specifiedretryingFuture
completes.- Specified by:
submit
in interfaceRetryingExecutor<ResponseT>
- Parameters:
retryingFuture
- the future previously returned bycreateFuture(Callable, RetryingContext)
- Returns:
- returns completed
retryingFuture
-
sleep
protected void sleep(org.threeten.bp.Duration delay) throws InterruptedException
This method simply callsThread.sleep(long)
.- Parameters:
delay
- time to sleep- Throws:
InterruptedException
- if any thread has interrupted the current thread
-
-