public class RetryUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
RetryUtils.CleanupAfterFailure |
static interface |
RetryUtils.Task<T> |
| Modifier and Type | Field and Description |
|---|---|
static long |
BASE_SLEEP_MILLIS |
static int |
DEFAULT_MAX_TRIES |
static Logger |
log |
static long |
MAX_SLEEP_MILLIS |
| Constructor and Description |
|---|
RetryUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
awaitNextRetry(Throwable e,
String messageOnRetry,
int nTry,
int maxRetries,
boolean quiet) |
static long |
nextRetrySleepMillis(int nTry) |
static <T> T |
retry(RetryUtils.Task<T> f,
com.google.common.base.Predicate<Throwable> shouldRetry,
int maxTries) |
static <T> T |
retry(RetryUtils.Task<T> f,
com.google.common.base.Predicate<Throwable> shouldRetry,
int quietTries,
int maxTries) |
static <T> T |
retry(RetryUtils.Task<T> f,
com.google.common.base.Predicate<Throwable> shouldRetry,
int quietTries,
int maxTries,
RetryUtils.CleanupAfterFailure cleanupAfterFailure,
String messageOnRetry)
Retry an operation using fuzzy exponentially increasing backoff.
|
static <T> T |
retry(RetryUtils.Task<T> f,
com.google.common.base.Predicate<Throwable> shouldRetry,
RetryUtils.CleanupAfterFailure onEachFailure,
int maxTries,
String messageOnRetry) |
public static final Logger log
public static final long MAX_SLEEP_MILLIS
public static final long BASE_SLEEP_MILLIS
public static final int DEFAULT_MAX_TRIES
public static <T> T retry(RetryUtils.Task<T> f, com.google.common.base.Predicate<Throwable> shouldRetry, int quietTries, int maxTries, @Nullable RetryUtils.CleanupAfterFailure cleanupAfterFailure, @Nullable String messageOnRetry) throws Exception
f - the operationshouldRetry - predicate determining whether we should retry after a particular exception thrown by "f"quietTries - first quietTries attempts will log exceptions at DEBUG level rather than WARNmaxTries - maximum number of attemptsException - if maxTries is exhausted, or shouldRetry returns falsepublic static <T> T retry(RetryUtils.Task<T> f, com.google.common.base.Predicate<Throwable> shouldRetry, int maxTries) throws Exception
Exceptionpublic static <T> T retry(RetryUtils.Task<T> f, com.google.common.base.Predicate<Throwable> shouldRetry, int quietTries, int maxTries) throws Exception
Exceptionpublic static <T> T retry(RetryUtils.Task<T> f, com.google.common.base.Predicate<Throwable> shouldRetry, RetryUtils.CleanupAfterFailure onEachFailure, int maxTries, String messageOnRetry) throws Exception
Exceptionpublic static void awaitNextRetry(Throwable e, @Nullable String messageOnRetry, int nTry, int maxRetries, boolean quiet) throws InterruptedException
InterruptedExceptionpublic static long nextRetrySleepMillis(int nTry)
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.