net.jini.core.transaction.server
Interface TransactionManager

All Known Subinterfaces:
NestableTransactionManager

public abstract interface TransactionManager
extends java.rmi.Remote, TransactionConstants

The interface used for managers of the two-phase commit protocol for top-level transactions. All ServerTransaction objects are goverened by a transaction manager that runs this protocol.

See Also:
NestableTransactionManager, ServerTransaction, TransactionParticipant

Inner Class Summary
static class TransactionManager.Created
          Class that holds return values from create methods.
 
Fields inherited from class net.jini.core.transaction.server.TransactionConstants
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING
 
Method Summary
 void abort(long id)
          Abort the transaction.
 void abort(long id, long waitFor)
          Abort the transaction, waiting for participants to be notified of the decision.
 void commit(long id)
          Commit the transaction.
 void commit(long id, long waitFor)
          Commit the transaction, waiting for participants to be notified of the decision.
 TransactionManager.Created create(long lease)
          Begin a new top-level transaction.
 int getState(long id)
          Returns the current state of the given transaction.
 void join(long id, TransactionParticipant part, long crashCount)
          Join a transaction that is managed by this transaction manager.
 

Method Detail

create

public TransactionManager.Created create(long lease)
                                  throws LeaseDeniedException,
                                         java.rmi.RemoteException
Begin a new top-level transaction.
Parameters:
lease - the requested lease time for the transaction
Returns:
the transaction id and the lease granted

join

public void join(long id,
                 TransactionParticipant part,
                 long crashCount)
          throws UnknownTransactionException,
                 CannotJoinException,
                 CrashCountException,
                 java.rmi.RemoteException
Join a transaction that is managed by this transaction manager. The crashCount marks the state of the storage used by the participant for transactions. If the participant attempts to join a transaction more than once, the crash counts must be the same. Each system crash or other event that destroys the state of the participant's unprepared transaction storage must cause the crash count to increase by at least one.
Parameters:
id - the transaction id
part - the participant joining the transaction
crashCount - the participant's current crash count
See Also:
ServerTransaction.join(net.jini.core.transaction.server.TransactionParticipant, long)

getState

public int getState(long id)
             throws UnknownTransactionException,
                    java.rmi.RemoteException
Returns the current state of the given transaction. The returned state can be any of the TransactionConstants values.
See Also:
ServerTransaction.getState(), TransactionConstants

commit

public void commit(long id)
            throws UnknownTransactionException,
                   CannotCommitException,
                   java.rmi.RemoteException
Commit the transaction. Commit asks the transaction manager to execute the voting process with the participants. Returns if the transaction successfully reaches either the NOTCHANGED or the COMMITTED state, without waiting for the transaction manager to notify all participants of the decision. If the transaction must be aborted (because one or more participants are unable to prepare), CannotCommitException is thrown without waiting for the transaction manager to notify all participants of the decision.
Parameters:
id - the transaction id

commit

public void commit(long id,
                   long waitFor)
            throws UnknownTransactionException,
                   CannotCommitException,
                   TimeoutExpiredException,
                   java.rmi.RemoteException
Commit the transaction, waiting for participants to be notified of the decision. Commit asks the transaction manager to execute the voting process with the participants. Returns if the transaction successfully reaches either the NOTCHANGED or the COMMITTED state, and the transaction manager has notified all participants of the decision, before the specified timeout expires. If the transaction must be aborted (because one or more participants are unable to prepare), CannotCommitException is thrown if the transaction manager is able to notify all participants of the decision before the specified timeout expires. If the transaction manager reaches a decision, but is unable to notify all participants of that decision before the specified timeout expires, then TimeoutExpiredException is thrown. If the specified timeout expires before the transaction manager reaches a decision, TimeoutExpiredException is not thrown until the manager reaches a decision.
Parameters:
id - the transaction id
waitFor - timeout to wait, from the start of the call until all participants have been notified of the transaction manager's decision

abort

public void abort(long id)
           throws UnknownTransactionException,
                  CannotAbortException,
                  java.rmi.RemoteException
Abort the transaction. This can be called at any time by any object holding a reference to the transaction. Abort asks the transaction manager to abort the transaction and to notify each participant of the decision, resulting in them rolling back any state changes made as part of the transaction. Returns as soon as the transaction manager records the abort decision, without waiting for the transaction manager to notify all participants of the decision.
Parameters:
id - the transaction id

abort

public void abort(long id,
                  long waitFor)
           throws UnknownTransactionException,
                  CannotAbortException,
                  TimeoutExpiredException,
                  java.rmi.RemoteException
Abort the transaction, waiting for participants to be notified of the decision. This can be called at any time by any object holding a reference to the transaction. Abort asks the transaction manager to abort the transaction and to notify each participant of the decision, resulting in them rolling back any state changes made as part of the transaction. Returns if the transaction manager records the decision and is able to notify all participants of the decision before the specified timeout expires. If the transaction manager is unable to notify all participants of the decision before the specified timeout expires, then TimeoutExpiredException is thrown.
Parameters:
id - the transaction id
waitFor - timeout to wait, from the start of the call until all participants have been notified of the transaction manager's decision


Copyright © 1999 Sun Microsystems, Inc. All rights reserved