Package org.apache.curator.retry
Class RetryNTimes
java.lang.Object
org.apache.curator.retry.RetryNTimes
- All Implemented Interfaces:
RetryPolicy
- Direct Known Subclasses:
RetryOneTime
Retry policy that retries a max number of times
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
allowRetry
(int retryCount, long elapsedTimeMs, RetrySleeper sleeper) Called when an operation has failed for some reason.int
getN()
protected long
getSleepTimeMs
(int retryCount, long elapsedTimeMs) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.curator.RetryPolicy
allowRetry
-
Constructor Details
-
RetryNTimes
public RetryNTimes(int n, int sleepMsBetweenRetries)
-
-
Method Details
-
getSleepTimeMs
protected long getSleepTimeMs(int retryCount, long elapsedTimeMs) -
getN
public int getN() -
allowRetry
Description copied from interface:RetryPolicy
Called when an operation has failed for some reason. This method should return true to make another attempt.- Specified by:
allowRetry
in interfaceRetryPolicy
- Parameters:
retryCount
- the number of times retried so far (0 the first time)elapsedTimeMs
- the elapsed time in ms since the operation was attemptedsleeper
- use this to sleep - DO NOT call Thread.sleep- Returns:
- true/false
-