Package org.duracloud.common.retry
Class Retrier
- java.lang.Object
-
- org.duracloud.common.retry.Retrier
-
public class Retrier extends Object
Handles performing actions that need to be retried. Expected usage example (using lambda): Retrier retrier = new Retrier(); return retrier.execute(() -> { // The actual method being executed return doWork(); }); Older style usage, this is equivalent to the above example: Retrier retrier = new Retrier(); return retrier.execute(new Retriable() {- Author:
- Bill Branan Date: 10/23/13
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_RETRIESDefault max number of attempts to make in performing a Retriable actionstatic intDEFAULT_WAIT_BETWEEN_RETRIESstatic intDEFAULT_WAIT_MULTIPLIER
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Texecute(Retriable retriable)Executes the action of a Retriable, and retries on error.<T> Texecute(Retriable retriable, ExceptionHandler exceptionHandler)Executes the action of a Retriable, and retries on error.
-
-
-
Field Detail
-
DEFAULT_MAX_RETRIES
public static final int DEFAULT_MAX_RETRIES
Default max number of attempts to make in performing a Retriable action- See Also:
- Constant Field Values
-
DEFAULT_WAIT_BETWEEN_RETRIES
public static final int DEFAULT_WAIT_BETWEEN_RETRIES
- See Also:
- Constant Field Values
-
DEFAULT_WAIT_MULTIPLIER
public static final int DEFAULT_WAIT_MULTIPLIER
- See Also:
- Constant Field Values
-
-
Method Detail
-
execute
public <T> T execute(Retriable retriable) throws Exception
Executes the action of a Retriable, and retries on error. Provides a way to execute a variety of methods and allow a retry to occur on method failure. Returns the necessary object type. This method, along with the Retriable interface is an implementation of the command pattern.- Parameters:
retriable-- Throws:
Exception
-
execute
public <T> T execute(Retriable retriable, ExceptionHandler exceptionHandler) throws Exception
Executes the action of a Retriable, and retries on error. Provides a way to execute a variety of methods and allow a retry to occur on method failure. Returns the necessary object type.- Parameters:
retriable-exceptionHandler- for customing handling of exceptions - especially with respect to customized logging.- Throws:
Exception
-
-