Class 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.

    • 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

      • 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:
        java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object