|
TransactionManagerA transaction manager looks after the two-phase commit protocol for all the participants in a transaction. It is responsible for creating a new transaction with its create() method. Any of the participants can force the transaction to abort by calling abort() , or they can force it to the two-phase commit stage by calling commit() . public interface TransactionManager { Created create(long leaseFor) throws ...; void join(long id, TransactionParticipant part, long crashCount) throws ...; void commit(long id) throws ...; void abort(long id) throws ...; ... } When a participant joins a transaction, it registers a listener of type TransactionParticipant . If any participant calls commit() , the transaction manager starts the voting process using all of these listeners. If all of these are prepared to commit, then the manager moves all of these listeners to the commit stage. Alternatively, any of the participants can call abort() , which forces all of the listeners to abort. |