Package net.jini.core.transaction.server
Interface TransactionParticipant
- All Superinterfaces:
Remote,TransactionConstants
- All Known Subinterfaces:
IRemoteSpace
- All Known Implementing Classes:
LRMISpaceImpl,SpaceImpl
The interface used for participants of the two-phase commit protocol. The methods on this
interface are called by the transaction manager. Any class that wants to have operations wrapped
in a transaction needs to support this interface. In conjunction with the
TransactionManager interface, this interface allows a two-phase commit protocol to
be used between objects in a distributed system.- Since:
- 1.0
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Field Summary
Fields inherited from interface net.jini.core.transaction.server.TransactionConstants
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING -
Method Summary
Modifier and TypeMethodDescriptionvoidabort(TransactionManager mgr, long id) Requests that the participant roll back any changes for the specified transaction and unlock any resources locked by the transaction.voidcommit(TransactionManager mgr, long id) Requests that the participant make all of itsPREPAREDchanges for the specified transaction visible outside of the transaction and unlock any resources locked by the transaction.voidcommit(TransactionManager mgr, long id, int numOfParticipants) Requests that the participant make all of itsPREPAREDchanges for the specified transaction visible outside of the transaction and unlock any resources locked by the transaction.intprepare(TransactionManager mgr, long id) Requests that the participant prepare itself to commit the transaction, and to vote on the outcome of the transaction.intprepareAndCommit(TransactionManager mgr, long id) A combination ofprepareandcommit, which can be used by the manager when there is just one participant left to prepare and all other participants (if any) have responded withNOTCHANGED.voidrenewLease(TransactionManager mgr, long id, long time) Notify the transaction participant about transaction lease renewal
-
Method Details
-
prepare
Requests that the participant prepare itself to commit the transaction, and to vote on the outcome of the transaction. The participant responds with eitherPREPARED, indicating that it is prepared;ABORT, indicating that it will abort, orNOTCHANGED, indicating that it did not have any state changed by the transaction (i.e., it was read-only). If the response isPREPARED, the participant must wait until it receives a commit or abort call from the transaction manager; it may query the transaction manager if needed as to the state of the transaction. If the response isABORT, the participant should roll its state back to undo any changes that occurred due to operations performed under the transaction; it can then discard any information about the transaction. If the response isNOTCHANGED, the participant can immediately discard any knowledge of the transaction.- Parameters:
mgr- the manager of the transactionid- the transaction ID- Returns:
- an
intrepresenting this participant's state - Throws:
UnknownTransactionException- if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.RemoteException- if there is a communication error
-
commit
Requests that the participant make all of itsPREPAREDchanges for the specified transaction visible outside of the transaction and unlock any resources locked by the transaction. All state associated with the transaction can then be discarded by the participant.- Parameters:
mgr- the manager of the transactionid- the transaction ID- Throws:
UnknownTransactionException- if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.RemoteException- if there is a communication error
-
commit
void commit(TransactionManager mgr, long id, int numOfParticipants) throws UnknownTransactionException, RemoteException Requests that the participant make all of itsPREPAREDchanges for the specified transaction visible outside of the transaction and unlock any resources locked by the transaction. All state associated with the transaction can then be discarded by the participant.- Parameters:
mgr- the manager of the transactionid- the transaction IDnumOfParticipants- the total number of transaction participants this is needed only in commit , since prepareAndCommit is called for single participant- Throws:
UnknownTransactionException- if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.RemoteException- if there is a communication error
-
abort
Requests that the participant roll back any changes for the specified transaction and unlock any resources locked by the transaction. All state associated with the transaction can then be discarded by the participant.- Parameters:
mgr- the manager of the transactionid- the transaction ID- Throws:
UnknownTransactionException- if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.RemoteException- if there is a communication error
-
prepareAndCommit
int prepareAndCommit(TransactionManager mgr, long id) throws UnknownTransactionException, RemoteException A combination ofprepareandcommit, which can be used by the manager when there is just one participant left to prepare and all other participants (if any) have responded withNOTCHANGED. The participant's implementation of this method must be equivalent to:public int prepareAndCommit(TransactionManager mgr, long id) throws UnknownTransactionException, RemoteException { int result = prepare(mgr, id); if (result == PREPARED) { commit(mgr, id); result = COMMITTED; } return result; }- Parameters:
mgr- the manager of the transactionid- the transaction ID- Returns:
- an
intrepresenting its state - Throws:
UnknownTransactionException- if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.RemoteException- if there is a communication error- See Also:
-
renewLease
void renewLease(TransactionManager mgr, long id, long time) throws LeaseDeniedException, UnknownLeaseException, RemoteException Notify the transaction participant about transaction lease renewal
-