Package io.tarantool.driver.api.retry
Class TarantoolRequestRetryPolicies.InfiniteRetryPolicy<T extends Predicate<Throwable>>
- java.lang.Object
-
- io.tarantool.driver.api.retry.TarantoolRequestRetryPolicies.InfiniteRetryPolicy<T>
-
- Type Parameters:
T
- exception checking callback function type
- All Implemented Interfaces:
RequestRetryPolicy
- Enclosing class:
- TarantoolRequestRetryPolicies
public static final class TarantoolRequestRetryPolicies.InfiniteRetryPolicy<T extends Predicate<Throwable>> extends Object implements RequestRetryPolicy
Retry policy that performs unbounded number of attempts. If the exception check passes, the policy returnstrue
.
-
-
Constructor Summary
Constructors Constructor Description InfiniteRetryPolicy(long requestTimeout, long operationTimeout, long delay, T exceptionCheck)
Basic constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRetryRequest(Throwable throwable)
A callback called when the request ends with an exception.long
getOperationTimeout()
long
getRequestTimeout()
Get timeout value for one retry attempt.<R> CompletableFuture<R>
wrapOperation(Supplier<CompletableFuture<R>> operation, Executor executor)
Wrap a generic operation taking an arbitrary number of arguments and returning aCompletableFuture
.
-
-
-
Constructor Detail
-
InfiniteRetryPolicy
public InfiniteRetryPolicy(long requestTimeout, long operationTimeout, long delay, T exceptionCheck)
Basic constructor- Parameters:
requestTimeout
- timeout for one retry attempt, in millisecondsoperationTimeout
- timeout for the whole operation, in millisecondsdelay
- delay between attempts, in millisecondsexceptionCheck
- predicate checking whether the given exception may be retried
-
-
Method Detail
-
canRetryRequest
public boolean canRetryRequest(Throwable throwable)
Description copied from interface:RequestRetryPolicy
A callback called when the request ends with an exception. Should returntrue
if and only if the request may be performed again (e.g. it is a timeout exception and it indicates only that the current server is overloaded). This may depend not only on the exception type, but also on the other conditions like the allowed number of retries or the maximum request execution time.Effective use of the retry policies may be achieved by combining them with multiple server connections and a
ConnectionSelectionStrategy
.- Specified by:
canRetryRequest
in interfaceRequestRetryPolicy
- Parameters:
throwable
- exception a request failed with- Returns:
- true if the request may be retried
-
getRequestTimeout
public long getRequestTimeout()
Description copied from interface:RequestRetryPolicy
Get timeout value for one retry attempt. The default value is 1 hour.- Specified by:
getRequestTimeout
in interfaceRequestRetryPolicy
- Returns:
- timeout value (ms), should be greater or equal to 0
-
getOperationTimeout
public long getOperationTimeout()
-
wrapOperation
public <R> CompletableFuture<R> wrapOperation(Supplier<CompletableFuture<R>> operation, Executor executor)
Description copied from interface:RequestRetryPolicy
Wrap a generic operation taking an arbitrary number of arguments and returning aCompletableFuture
. Each operation attempt is limited with a timeout returned byRequestRetryPolicy.getRequestTimeout()
. SeeTarantoolRequestRetryPolicies.InfiniteRetryPolicy
for example of implementation.- Specified by:
wrapOperation
in interfaceRequestRetryPolicy
- Type Parameters:
R
- operation result type- Parameters:
operation
- supplier for the operation to perform. Must return a new operation instanceexecutor
- executor in which the retry callbacks will be scheduled- Returns:
CompletableFuture
with the same type as the operation result type
-
-