Package org.xbib.netty.http.client.api
Interface BackOff
-
public interface BackOffBack-off policy when retrying an operation.
-
-
Field Summary
Fields Modifier and Type Field Description static longSTOPIndicates that no more retries should be made for use innextBackOffMillis().static BackOffSTOP_BACKOFFFixed back-off policy that always returns#STOPfornextBackOffMillis(), meaning that the operation should not be retried.static BackOffZERO_BACKOFFFixed back-off policy whose back-off time is always zero, meaning that the operation is retried immediately without waiting.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longnextBackOffMillis()Gets the number of milliseconds to wait before retrying the operation orSTOPto indicate that no retries should be made.voidreset()Reset to initial state.
-
-
-
Field Detail
-
STOP
static final long STOP
Indicates that no more retries should be made for use innextBackOffMillis().- See Also:
- Constant Field Values
-
ZERO_BACKOFF
static final BackOff ZERO_BACKOFF
Fixed back-off policy whose back-off time is always zero, meaning that the operation is retried immediately without waiting.
-
STOP_BACKOFF
static final BackOff STOP_BACKOFF
Fixed back-off policy that always returns#STOPfornextBackOffMillis(), meaning that the operation should not be retried.
-
-
Method Detail
-
reset
void reset()
Reset to initial state.
-
nextBackOffMillis
long nextBackOffMillis()
Gets the number of milliseconds to wait before retrying the operation orSTOPto indicate that no retries should be made.- Returns:
- milliseconds before operation retry
Example usage:
long backOffMillis = backoff.nextBackOffMillis(); if (backOffMillis == Backoff.STOP) { // do not retry operation } else { // sleep for backOffMillis milliseconds and retry operation }
-
-