@Deprecated public class RetryManager extends Object
The function must be a Java8 Supplier, which returns a value. Use
a lambda to wrap calls that don't return a value (to retry operations that may
throw a non-fatal exception).
| Constructor and Description |
|---|
RetryManager(Duration initialDuration,
Duration timeout,
boolean isExponential)
Deprecated.
Constructor for those preferring Java8 durations.
|
RetryManager(long initialDuration,
long timeout,
boolean isExponential)
Deprecated.
Constructor for those who like to specify times in milliseconds.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
invoke(Supplier<T> supplier)
Deprecated.
Invokes the passed function.
|
<T> T |
invoke(Supplier<T> supplier,
Consumer<RuntimeException> exceptionHandler)
Deprecated.
Invokes the passed function.
|
static boolean |
sleepQuietly(long duration)
Deprecated.
Sleeps for the specified duration (in milliseconds).
|
public RetryManager(long initialDuration,
long timeout,
boolean isExponential)
initialDuration - The initial time, in milliseconds, to wait between calls.timeout - The maximum time, in milliseconds, to attempt calls. The
number of calls attempted will depend on initialDuration
and the wait strategy.isExponential - If true, then the sleep duration is doubled for every attempt.
If false, the sleeps are of equal length.public RetryManager(Duration initialDuration, Duration timeout, boolean isExponential)
initialDuration - The initial time to wait between calls.timeout - The maximum time to attempt calls. The number of
calls attempted will depend on initialDuration
and the wait strategy.isExponential - If true, then the sleep duration is doubled for
every attempt.public <T> T invoke(Supplier<T> supplier)
If the thread is interrupted, this method terminates and returns null.
public <T> T invoke(Supplier<T> supplier, Consumer<RuntimeException> exceptionHandler)
RuntimeException, since Supplier is not permitted
to throw arbitrary exceptions.
If the thread is interrupted, this method terminates and returns null.
public static boolean sleepQuietly(long duration)
true if
the sleep completes normally, false if the thread is interrupted.Copyright © 2023. All rights reserved.