Package io.atlassian.fugue.retry
Class BeforeRetryExponentialBackoffTask
- java.lang.Object
-
- io.atlassian.fugue.retry.BeforeRetryExponentialBackoffTask
-
- All Implemented Interfaces:
java.lang.Runnable
public class BeforeRetryExponentialBackoffTask extends java.lang.Object implements java.lang.RunnableA backoff task for use in a retry -function, -supplier, or -task. This should be used as the beforeRetry hook. Upon each execution, the amount of time to wait before retrying the function call is doubled. This class maintains an internal state; we recommend creating a new instance for each use.
-
-
Field Summary
Fields Modifier and Type Field Description private longbackoff
-
Constructor Summary
Constructors Constructor Description BeforeRetryExponentialBackoffTask(long backoffMillis)Constructor for BeforeRetryExponentialBackoffTask.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) longcurrentBackoff()voidrun()This method causes the current thread to sleep for a duration which doubles after each successive call.
-
-
-
Constructor Detail
-
BeforeRetryExponentialBackoffTask
public BeforeRetryExponentialBackoffTask(long backoffMillis)
Constructor for BeforeRetryExponentialBackoffTask.
- Parameters:
backoffMillis- the amount of time to wait, in milliseconds before retrying the first time. This is doubled for each subsequent retry. This parameter must be above zero.
-
-
Method Detail
-
run
public void run()
This method causes the current thread to sleep for a duration which doubles after each successive call. InterruptedExceptions are wrapped before being rethrown in a RuntimeException.- Specified by:
runin interfacejava.lang.Runnable
-
currentBackoff
long currentBackoff()
-
-