Package alluxio.retry
Class SleepingRetry
- java.lang.Object
-
- alluxio.retry.SleepingRetry
-
- All Implemented Interfaces:
RetryPolicy
- Direct Known Subclasses:
ExponentialBackoffRetry
@NotThreadSafe public abstract class SleepingRetry extends java.lang.Object implements RetryPolicy
A retry policy that uses thread sleeping for the delay.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SleepingRetry(int maxRetries)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
attempt()
Waits until it is time to perform the next retry, then returns.int
getAttemptCount()
How many retries have been performed.protected abstract long
getSleepTime()
How long to sleep before the next retry is performed.protected java.util.concurrent.TimeUnit
getSleepUnit()
Unit of time thatgetSleepTime()
is measured in.
-
-
-
Method Detail
-
getAttemptCount
public int getAttemptCount()
Description copied from interface:RetryPolicy
How many retries have been performed. If no retries have been performed, 0 is returned.- Specified by:
getAttemptCount
in interfaceRetryPolicy
- Returns:
- number of retries performed
-
attempt
public boolean attempt()
Description copied from interface:RetryPolicy
Waits until it is time to perform the next retry, then returns. Returns false if no further retries should be performed. The first call to this method should never delay the caller, this allow users of the policy to use it in the context of a while-loop.- Specified by:
attempt
in interfaceRetryPolicy
- Returns:
- whether another retry should be performed
-
getSleepUnit
protected java.util.concurrent.TimeUnit getSleepUnit()
Unit of time thatgetSleepTime()
is measured in. Defaults toTimeUnit.MILLISECONDS
.
-
getSleepTime
protected abstract long getSleepTime()
How long to sleep before the next retry is performed. This method is used withgetSleepUnit()
, so all time given here must match the unit provided.
-
-