public class ExponentialBackoff extends Object implements 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
|
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 Comparable<ExponentialBackoff>
Copyright © 2016. All rights reserved.