Package org.duracloud.common.retry
Class Retrier
java.lang.Object
org.duracloud.common.retry.Retrier
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
FieldsModifier and TypeFieldDescriptionstatic final intDefault max number of attempts to make in performing a Retriable actionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TExecutes 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 Details
-
DEFAULT_MAX_RETRIES
public static final int DEFAULT_MAX_RETRIESDefault max number of attempts to make in performing a Retriable action- See Also:
-
DEFAULT_WAIT_BETWEEN_RETRIES
public static final int DEFAULT_WAIT_BETWEEN_RETRIES- See Also:
-
DEFAULT_WAIT_MULTIPLIER
public static final int DEFAULT_WAIT_MULTIPLIER- See Also:
-
-
Constructor Details
-
Retrier
public Retrier() -
Retrier
public Retrier(int maxRetries) - Parameters:
maxRetries-
-
Retrier
public Retrier(int maxRetries, int waitBetweenRetries, int waitBetweenRetriesMultiplier) - Parameters:
maxRetries-waitBetweenRetries-waitBetweenRetriesMultiplier-
-
-
Method Details
-
execute
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
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
-