RetryPolicy
BoundedExponentialBackoffRetry
public class ExponentialBackoffRetry extends Object
Constructor | Description |
---|---|
ExponentialBackoffRetry(int baseSleepTimeMs,
int maxRetries) |
|
ExponentialBackoffRetry(int baseSleepTimeMs,
int maxRetries,
int maxSleepMs) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
allowRetry(int retryCount,
long elapsedTimeMs,
RetrySleeper sleeper) |
Called when an operation has failed for some reason.
|
int |
getBaseSleepTimeMs() |
|
int |
getN() |
|
protected long |
getSleepTimeMs(int retryCount,
long elapsedTimeMs) |
public ExponentialBackoffRetry(int baseSleepTimeMs, int maxRetries)
baseSleepTimeMs
- initial amount of time to wait between retriesmaxRetries
- max number of times to retrypublic ExponentialBackoffRetry(int baseSleepTimeMs, int maxRetries, int maxSleepMs)
baseSleepTimeMs
- initial amount of time to wait between retriesmaxRetries
- max number of times to retrymaxSleepMs
- max time in ms to sleep on each retrypublic int getBaseSleepTimeMs()
protected long getSleepTimeMs(int retryCount, long elapsedTimeMs)
public int getN()
public boolean allowRetry(int retryCount, long elapsedTimeMs, RetrySleeper sleeper)
RetryPolicy
allowRetry
in interface RetryPolicy
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.sleepCopyright © 2011–2018 The Apache Software Foundation. All rights reserved.