T - The type of the object that will be returned by the flaky supplier functionpublic class RetryUtil<T>
extends java.lang.Object
RetryUtil for every operation that needs to retried for the stated retries.
Limitations:
WaitStrategies.exponentialWait() and
WaitStrategies.randomWait(long, TimeUnit) with fixed attributes for each of the strategies.
| Constructor and Description |
|---|
RetryUtil() |
| Modifier and Type | Method and Description |
|---|---|
T |
retryOnException(java.util.function.Supplier<T> supplierCommand,
com.google.common.base.Predicate<java.lang.Throwable> throwablePredicate,
com.google.common.base.Predicate<T> resultRetryPredicate,
int retryCount,
java.lang.String shortDescription,
java.lang.String operationName)
A helper method which has the ability to execute a flaky supplier function and retry in case of failures.
|
public T retryOnException(java.util.function.Supplier<T> supplierCommand, com.google.common.base.Predicate<java.lang.Throwable> throwablePredicate, com.google.common.base.Predicate<T> resultRetryPredicate, int retryCount, java.lang.String shortDescription, java.lang.String operationName) throws java.lang.RuntimeException
supplierCommand: - Any function that is flaky and needs multiple retries.throwablePredicate: - A Guava Predicate housing the exceptional
criteria to perform informed filtering before retrying.resultRetryPredicate: - a predicate to be evaluated for a valid condition of the expected resultretryCount: - Number of times the function is to be retried before failureshortDescription: - A short description of the function that will be used in logging and error propagation.
The intention of this description is to provide context for Operability.operationName: - The name of the function for traceability in logsjava.lang.RuntimeException - in case of failed attempts to get T, which needs to be returned by the supplierCommand.
The instance of the returned exception has:
Attempt of the retry