org.multiverse.utils.backoff
Interface BackoffPolicy

All Known Implementing Classes:
ExponentialBackoffPolicy, NoOpBackoffPolicy

public interface BackoffPolicy

A policy that can be used to backoff when it can't make progress because other transactions are interfering. A lot of interference means that there is a lot of contention and with a backoff policy it means that you can reduce contention by delaying certain transactions, so that the chance increases for some of them to make progress and eventually make the way free for the others.

The delayedUninterruptible(org.multiverse.api.Transaction , int) needs the transaction, so that different dalays can be done based on the transaction. For example a transaction that has a higher priority could get a smaller delay than a transaction with a lower priority.

Interruptable and non interruptable delay methods are provided.

Author:
Peter Veentjer.

Method Summary
 void delay(Transaction tx, int attempt)
          Executes the delay.
 void delayedUninterruptible(Transaction tx, int attempt)
          Executes the delay without the possibility of being interrupted.
 

Method Detail

delay

void delay(Transaction tx,
           int attempt)
           throws java.lang.InterruptedException
Executes the delay. This call is interruptible.

Parameters:
tx - 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.
Throws:
java.lang.NullPointerException - if t is null. It depends on the implementation if this is checked.
java.lang.IllegalArgumentException - if attempt smaller than 1. It depends on the implementation if this is checked.
java.lang.InterruptedException - if the delay is interrupted.

delayedUninterruptible

void delayedUninterruptible(Transaction tx,
                            int attempt)
Executes the delay without the possibility of being interrupted.

Parameters:
tx - 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.
Throws:
java.lang.NullPointerException - if t is null. It depends on the implementation if this is checked.
java.lang.IllegalArgumentException - if attempt smaller than 1. It depends on the implementation if this is checked.


Copyright © 2008-2010 Multiverse. All Rights Reserved.