|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.multiverse.utils.backoff.ExponentialBackoffPolicy
public class ExponentialBackoffPolicy
A BackoffPolicy that does an exponential backoff. So each next attempt, the delay is doubled until a
configurable maximum delay has been reached.
| Field Summary | |
|---|---|
static ExponentialBackoffPolicy |
INSTANCE_10_MS_MAX
|
| Constructor Summary | |
|---|---|
ExponentialBackoffPolicy()
Creates an ExponentialBackoffPolicy with 100 nanoseconds as minimal delay and 10 milliseconds as maximum delay. |
|
ExponentialBackoffPolicy(long minDelayNs,
long maxDelay,
java.util.concurrent.TimeUnit unit)
Creates an ExponentialBackoffPolicy with given maximum delay. |
|
| Method Summary | |
|---|---|
protected long |
calcDelayNs(int attempt)
|
void |
delay(Transaction t,
int attempt)
Executes the delay. |
void |
delayedUninterruptible(Transaction t,
int attempt)
Executes the delay without the possibility of being interrupted. |
long |
getMaxDelayNs()
Returns the maximum delay in nanoseconds. |
long |
getMinDelayNs()
Returns the minimum delay in nanoseconds. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final ExponentialBackoffPolicy INSTANCE_10_MS_MAX
| Constructor Detail |
|---|
public ExponentialBackoffPolicy()
public ExponentialBackoffPolicy(long minDelayNs,
long maxDelay,
java.util.concurrent.TimeUnit unit)
minDelayNs - the minimum delay in nanoseconds to wait. If a negative or zero value provided, it will be
interpreted that no external minimal value is needed.maxDelay - the maximum delay.unit - the unit of maxDelay.
java.lang.NullPointerException - if unit is null.| Method Detail |
|---|
public long getMaxDelayNs()
public long getMinDelayNs()
public void delay(Transaction t,
int attempt)
throws java.lang.InterruptedException
BackoffPolicy
delay in interface BackoffPolicyt - the transaction that is going to be restarted. The transaction should never be null, but it
depends on the implementation if this is checked.attempt - indicates the number of times the transaction is tried. Attempt should always be equal or larger
than 1. It depends on the implementation if this is checked.
java.lang.InterruptedException - if the delay is interrupted.
public void delayedUninterruptible(Transaction t,
int attempt)
BackoffPolicy
delayedUninterruptible in interface BackoffPolicyt - the transaction that is going to be restarted. The transaction should never be null, but it
depends on the implementation if this is checked.attempt - indicates the number of times the transaction is tried. Attempt should always be equal or larger
than 1. It depends on the implementation if this is checked.protected long calcDelayNs(int attempt)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||