org.multiverse.commitbarriers
Class VetoCommitBarrier

java.lang.Object
  extended by org.multiverse.commitbarriers.CommitBarrier
      extended by org.multiverse.commitbarriers.VetoCommitBarrier

public final class VetoCommitBarrier
extends CommitBarrier

The VetoCommitBarrier is a synchronization primitive that makes it possible to execute a 2 phase commit; so all transaction within a VetoCommitBarrier commit, or they all abort. The VetoCommitBarrier is useful if there is a veto situation; so one transaction is able to commit all others.

This structure is thread-safe to use.

Author:
Peter Veentjer.

Field Summary
 
Fields inherited from class org.multiverse.commitbarriers.CommitBarrier
lock, statusCondition
 
Constructor Summary
VetoCommitBarrier()
          Creates a new VetoCommitBarrier that uses an unfair Lock.
VetoCommitBarrier(boolean fair)
          Creates a new VetoCommitBarrier.
 
Method Summary
 void atomicVetoCommit()
          Veto's the commit so that all prepared Transactions in this VetoCommitBarriers should commit.
protected  boolean isLastParty()
           
 String toString()
           
 void vetoCommit(Txn tx)
          Veto's the commit of this VetoCommitBarrier including the provided transaction.
 
Methods inherited from class org.multiverse.commitbarriers.CommitBarrier
abort, addJoiner, awaitOpen, awaitOpenUninterruptibly, ensureNotDead, executeTasks, finish, getNumberWaiting, getStatus, isAborted, isClosed, isCommitted, joinCommit, joinCommitUninterruptibly, registerOnAbortTask, registerOnCommitTask, setScheduledExecutorService, setTimeout, signalAborted, signalCommit, tryAwaitOpen, tryAwaitOpenUninterruptibly, tryJoinCommit, tryJoinCommit, tryJoinCommitUninterruptibly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VetoCommitBarrier

public VetoCommitBarrier()
Creates a new VetoCommitBarrier that uses an unfair Lock.


VetoCommitBarrier

public VetoCommitBarrier(boolean fair)
Creates a new VetoCommitBarrier.

Parameters:
fair - if the lock should be fair.
Method Detail

isLastParty

protected boolean isLastParty()
Specified by:
isLastParty in class CommitBarrier

atomicVetoCommit

public void atomicVetoCommit()
Veto's the commit so that all prepared Transactions in this VetoCommitBarriers should commit. This call doesn't block (for a long time).

It could be that this method finishes before the other parties have completed their commit. In most cases this won't be an issue, because the other parties have prepared their transactions, so all needed resources are locked.

If the VetoCommitBarrier already is committed, this call is ignored.

After the commit completes, the onCommitTasks are executed.

Throws:
CommitBarrierOpenException - if the VetoCommitBarrier already is aborted.

vetoCommit

public void vetoCommit(Txn tx)
Veto's the commit of this VetoCommitBarrier including the provided transaction. If all goes well all pending transactions and the provided transaction are going to commit.

It could be that this method finishes before the other parties have completed their commit. In most cases this won't be an issue, because the other parties have prepared their transactions, so all needed resources are locked.

If the VetoCommitBarrier already is aborted or committed, the transaction is aborted.

Parameters:
tx - the Txn to commit.
Throws:
NullPointerException - if tx is null.
DeadTxnException - if the Txn already is aborted or committed.
ReadWriteConflict - if the commit was not executed successfully.
CommitBarrierOpenException - if the VetoCommitBarrier already is open.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.