public class ExponentialBackoff extends java.lang.Object implements java.lang.Comparable<ExponentialBackoff>
Tracks successes and failures and calculates a time to retry the operation.
The retries are exponentially backed off, up to a maximum interval. On success the back off interval is reset.
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
ExponentialBackoff.Params
Parameters to configure a particular kind of exponential backoff. 
 | 
| Modifier and Type | Field and Description | 
|---|---|
static int | 
DEFAULT_INITIAL_MILLIS  | 
static int | 
DEFAULT_MAXIMUM_MILLIS  | 
static float | 
DEFAULT_MULTIPLIER  | 
| Constructor and Description | 
|---|
ExponentialBackoff(ExponentialBackoff.Params params)  | 
| Modifier and Type | Method and Description | 
|---|---|
int | 
compareTo(ExponentialBackoff other)  | 
long | 
getRetryTime()
Get the next time to retry, in milliseconds since the epoch 
 | 
java.lang.String | 
toString()  | 
void | 
trackFailure()
Track a failure - multiply the back off interval by the multiplier 
 | 
void | 
trackSuccess()
Track a success - reset back off interval to the initial value 
 | 
public static final int DEFAULT_INITIAL_MILLIS
public static final float DEFAULT_MULTIPLIER
public static final int DEFAULT_MAXIMUM_MILLIS
public ExponentialBackoff(ExponentialBackoff.Params params)
public final void trackSuccess()
public void trackFailure()
public long getRetryTime()
public int compareTo(ExponentialBackoff other)
compareTo in interface java.lang.Comparable<ExponentialBackoff>public java.lang.String toString()
toString in class java.lang.Object