Package io.atlassian.fugue.retry
Class RetryFactory
- java.lang.Object
-
- io.atlassian.fugue.retry.RetryFactory
-
public class RetryFactory extends java.lang.ObjectProvides factory methods for RetryFunction, RetryTask, and RetrySupplier. These classes can be used when a task is known to fail on occasion and no other workaround is known. This class is not instantiable.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateRetryFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Runnablecreate(java.lang.Runnable task, int tries)Decorates a runnable so that it retries a number of times before being allowed to fail.static java.lang.Runnablecreate(java.lang.Runnable task, int tries, ExceptionHandler handler)Decorates a runnable so that it retries a number of times before being allowed to fail.static java.lang.Runnablecreate(java.lang.Runnable task, int tries, ExceptionHandler handler, long backoff)Decorates a runnable so that it retries a number of times before being allowed to fail, backing off exponentially in time.static <A,B>
java.util.function.Function<A,B>create(java.util.function.Function<A,B> function, int tries)Decorates a function so that it retries a number of times before being allowed to fail.static <A,B>
java.util.function.Function<A,B>create(java.util.function.Function<A,B> function, int tries, ExceptionHandler handler)Decorates a function so that it retries a number of times before being allowed to fail.static <A,B>
java.util.function.Function<A,B>create(java.util.function.Function<A,B> function, int tries, ExceptionHandler handler, long backoff)Decorates a function so that it retries a number of times before being allowed to fail.static <A> java.util.function.Supplier<A>create(java.util.function.Supplier<A> supplier, int tries)Decorates a supplier so that it retries a number of times before being allowed to fail.static <A> java.util.function.Supplier<A>create(java.util.function.Supplier<A> supplier, int tries, ExceptionHandler handler)Decorates a supplier so that it retries a number of times before being allowed to fail.static <A> java.util.function.Supplier<A>create(java.util.function.Supplier<A> supplier, int tries, ExceptionHandler handler, long backoff)Decorates a supplier so that it retries a number of times before being allowed to fail, backing-off in time exponentially.
-
-
-
Method Detail
-
create
public static java.lang.Runnable create(java.lang.Runnable task, int tries)Decorates a runnable so that it retries a number of times before being allowed to fail.- Parameters:
task- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the call- Returns:
- a runnable which can be used to call another runnable multiple times when that runnable may fail sporadically
-
create
public static java.lang.Runnable create(java.lang.Runnable task, int tries, ExceptionHandler handler)Decorates a runnable so that it retries a number of times before being allowed to fail.- Parameters:
task- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- passed any exceptions that are encountered- Returns:
- a runnable which can be used to call another runnable multiple times when that runnable may fail sporadically
-
create
public static java.lang.Runnable create(java.lang.Runnable task, int tries, ExceptionHandler handler, long backoff)Decorates a runnable so that it retries a number of times before being allowed to fail, backing off exponentially in time.- Parameters:
task- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplierbackoff- time to wait in millis each time- Returns:
- a runnable which can be used to call another runnable multiple times when that runnable may fail sporadically
-
create
public static <A> java.util.function.Supplier<A> create(java.util.function.Supplier<A> supplier, int tries)Decorates a supplier so that it retries a number of times before being allowed to fail.- Type Parameters:
A- The type of the object returned by supplier- Parameters:
supplier- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the call- Returns:
- a supplier which can be used to call another supplier multiple times when that supplier may fail sporadically
-
create
public static <A> java.util.function.Supplier<A> create(java.util.function.Supplier<A> supplier, int tries, ExceptionHandler handler)Decorates a supplier so that it retries a number of times before being allowed to fail.- Type Parameters:
A- The type of the object returned by supplier- Parameters:
supplier- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplier- Returns:
- a supplier which can be used to call another supplier multiple times when that supplier may fail sporadically
-
create
public static <A> java.util.function.Supplier<A> create(java.util.function.Supplier<A> supplier, int tries, ExceptionHandler handler, long backoff)Decorates a supplier so that it retries a number of times before being allowed to fail, backing-off in time exponentially.- Type Parameters:
A- The type of the object returned by supplier- Parameters:
supplier- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplierbackoff- time to wait in millis each time- Returns:
- a supplier which can be used to call another supplier multiple times when that supplier may fail sporadically
-
create
public static <A,B> java.util.function.Function<A,B> create(java.util.function.Function<A,B> function, int tries)Decorates a function so that it retries a number of times before being allowed to fail.- Type Parameters:
A- the type of the parameter the function acceptsB- the type of the result of the function's apply method- Parameters:
function- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the call- Returns:
- a function which can be used to invoke another function multiple times when that function may fail sporadically
-
create
public static <A,B> java.util.function.Function<A,B> create(java.util.function.Function<A,B> function, int tries, ExceptionHandler handler)Decorates a function so that it retries a number of times before being allowed to fail.- Type Parameters:
A- the type of the parameter the function acceptsB- the type of the result of the function's apply method- Parameters:
function- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplier- Returns:
- a function which can be used to invoke another function multiple times when that function may fail sporadically
-
create
public static <A,B> java.util.function.Function<A,B> create(java.util.function.Function<A,B> function, int tries, ExceptionHandler handler, long backoff)Decorates a function so that it retries a number of times before being allowed to fail.- Type Parameters:
A- the type of the parameter the function acceptsB- the type of the result of the function's apply method- Parameters:
function- which will be wrapped for retrial. It should be idempotent on failure.tries- the number of times to re-attempt the callhandler- which acts on exceptions thrown by the wrapped supplierbackoff- time to wait in millis each time- Returns:
- a function which can be used to invoke another function multiple times when that function may fail sporadically
-
-