public final class Retries extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
delay(int ms,
int nanos)
Suspends the current thread for a specified number of millis and nanos.
|
static void |
randomDelay(int ms)
Suspends the current thread for a random number of millis between 0 and
the indicated limit.
|
static <U,V> Function<U,V> |
retryable(Function<U,V> base,
Class<? extends Throwable> exceptionClass,
int maxRetries,
int maxDelayBetweenRetries)
Returns a function that retries execution on failure.
|
static <V> Supplier<V> |
retryable(Supplier<V> base,
Class<? extends Throwable> exceptionClass,
int maxRetries,
int maxDelayBetweenRetries)
Returns a Supplier that retries execution on failure.
|
public static <U,V> Function<U,V> retryable(Function<U,V> base, Class<? extends Throwable> exceptionClass, int maxRetries, int maxDelayBetweenRetries)
U - type of function inputV - type of function outputbase - base functionexceptionClass - type of exception for which to retrymaxRetries - max number of retries before giving upmaxDelayBetweenRetries - max delay between successive retries. The actual delay is randomly picked from
the interval (0, maxDelayBetweenRetries]public static <V> Supplier<V> retryable(Supplier<V> base, Class<? extends Throwable> exceptionClass, int maxRetries, int maxDelayBetweenRetries)
V - type of supplied resultbase - base supplierexceptionClass - type of exception for which to retrymaxRetries - max number of retries before giving upmaxDelayBetweenRetries - max delay between successive retries. The actual delay is randomly picked from
the interval (0, maxDelayBetweenRetries]public static void randomDelay(int ms)
ms - max number of millispublic static void delay(int ms,
int nanos)
ms - number of millisnanos - number of nanosCopyright © 2013–2019. All rights reserved.