Package org.bitcoinj.utils
Class ExponentialBackoff
java.lang.Object
org.bitcoinj.utils.ExponentialBackoff
- All Implemented Interfaces:
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Parameters to configure a particular kind of exponential backoff. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final float
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(ExponentialBackoff other) long
Get the next time to retry, in milliseconds since the epochtoString()
void
Track a failure - multiply the back off interval by the multiplierfinal void
Track a success - reset back off interval to the initial value
-
Field Details
-
DEFAULT_INITIAL_MILLIS
public static final int DEFAULT_INITIAL_MILLIS- See Also:
-
DEFAULT_MULTIPLIER
public static final float DEFAULT_MULTIPLIER- See Also:
-
DEFAULT_MAXIMUM_MILLIS
public static final int DEFAULT_MAXIMUM_MILLIS- See Also:
-
-
Constructor Details
-
ExponentialBackoff
-
-
Method Details
-
trackSuccess
public final void trackSuccess()Track a success - reset back off interval to the initial value -
trackFailure
public void trackFailure()Track a failure - multiply the back off interval by the multiplier -
getRetryTime
public long getRetryTime()Get the next time to retry, in milliseconds since the epoch -
compareTo
- Specified by:
compareTo
in interfaceComparable<ExponentialBackoff>
-
toString
-