org.multiverse.commitbarriers
Class VetoCommitBarrier
java.lang.Object
org.multiverse.commitbarriers.CommitBarrier
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.
|
Method Summary |
protected boolean |
isLastParty()
|
void |
vetoCommit()
Veto's the commit so that all prepared Transactions in this VetoCommitBarriers should commit. |
void |
vetoCommit(Transaction 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, toString, wait, wait, wait |
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.
isLastParty
protected boolean isLastParty()
- Specified by:
isLastParty in class CommitBarrier
vetoCommit
public void vetoCommit()
- 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(Transaction 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 Transaction to commit.
- Throws:
java.lang.NullPointerException - if tx is null.
DeadTransactionException - if the Transaction already is aborted or committed.
WriteConflict - if the commit was not executed successfully.
CommitBarrierOpenException - if the VetoCommitBarrier already is open.
Copyright © 2008-2010 Multiverse. All Rights Reserved.