public class Retry extends Object
| Modifier and Type | Class and Description | 
|---|---|
static interface  | 
Retry.AdvancedRunnable
Runnable, which provides some additional info (iteration for now) 
 | 
static interface  | 
Retry.Supplier<T>
Needed here because:
 - java.util.function.Supplier defined from Java 8
 - Adds some additional info (current iteration) 
 | 
static interface  | 
Retry.ThrowableCallback
Needed here because:
 - java.util.function.BiConsumer defined from Java 8
 - Adds some additional info (current iteration and called throwable 
 | 
| Constructor and Description | 
|---|
Retry()  | 
| Modifier and Type | Method and Description | 
|---|---|
static <T> T | 
call(Retry.Supplier<T> supplier,
    int attemptsCount,
    long intervalMillis)
Runs the given  
runnable at most attemptsCount times until it passes,
 leaving intervalMillis milliseconds between the invocations. | 
static int | 
execute(Runnable runnable,
       int attemptsCount,
       long intervalMillis)
Runs the given  
runnable at most attemptsCount times until it passes,
 leaving intervalMillis milliseconds between the invocations. | 
static int | 
executeWithBackoff(Retry.AdvancedRunnable runnable,
                  int attemptsCount,
                  int intervalBaseMillis)
Runs the given  
runnable at most attemptsCount times until it passes,
 leaving some increasing random delay milliseconds between the invocations. | 
static int | 
executeWithBackoff(Retry.AdvancedRunnable runnable,
                  Retry.ThrowableCallback throwableCallback,
                  int attemptsCount,
                  int intervalBaseMillis)  | 
public static int execute(Runnable runnable, int attemptsCount, long intervalMillis)
runnable at most attemptsCount times until it passes,
 leaving intervalMillis milliseconds between the invocations.
 The runnable is reexecuted if it throws a RuntimeException or AssertionError.runnable - attemptsCount - Total number of attempts to execute the runnableintervalMillis - public static int executeWithBackoff(Retry.AdvancedRunnable runnable, int attemptsCount, int intervalBaseMillis)
runnable at most attemptsCount times until it passes,
 leaving some increasing random delay milliseconds between the invocations. It uses Exponential backoff + jitter algorithm
 to compute the delay. More details https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
 The base for delay is specified by intervalBaseMillis number.
 The runnable is reexecuted if it throws a RuntimeException or AssertionError.runnable - attemptsCount - Total number of attempts to execute the runnableintervalBaseMillis - base for the exponential backoff + jitterpublic static int executeWithBackoff(Retry.AdvancedRunnable runnable, Retry.ThrowableCallback throwableCallback, int attemptsCount, int intervalBaseMillis)
public static <T> T call(Retry.Supplier<T> supplier, int attemptsCount, long intervalMillis)
runnable at most attemptsCount times until it passes,
 leaving intervalMillis milliseconds between the invocations.
 The runnable is reexecuted if it throws a RuntimeException or AssertionError.supplier - attemptsCount - Total number of attempts to execute the runnableintervalMillis - supplier.Copyright © 2021 JBoss by Red Hat. All rights reserved.