GigaSpaces XAP 9.7.2 API

net.jini.core.transaction.server
Class ServerTransaction

java.lang.Object
  extended by net.jini.core.transaction.server.ServerTransaction
All Implemented Interfaces:
com.gigaspaces.internal.server.space.redolog.storage.bytebuffer.ISwapExternalizable, Externalizable, Serializable, ManagedTransaction, Transaction
Direct Known Subclasses:
NestableServerTransaction

public class ServerTransaction
extends Object
implements ManagedTransaction, Serializable, Externalizable, com.gigaspaces.internal.server.space.redolog.storage.bytebuffer.ISwapExternalizable

Class implementing the Transaction interface, for use with transaction participants that implement the default transaction semantics.

Since:
1.0
Author:
Sun Microsystems, Inc.
See Also:
Transaction, NestableServerTransaction, TransactionManager, TransactionFactory, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.jini.core.transaction.Transaction
Transaction.Created
 
Field Summary
static long EMBEDDED_CRASH_COUNT
           
 long id
          The transaction id.
 ExtendedTransactionManager mgr
          The transaction manager.
 
Constructor Summary
ServerTransaction()
          Do not use, required for externalizable
ServerTransaction(TransactionManager mgr, long id)
           
ServerTransaction(TransactionManager mgr, long id, long lease)
          Simple constructor.
ServerTransaction(TransactionManager mgr, long id, TransactionParticipantDataImpl metaData)
           
 
Method Summary
 void abort()
          Abort the transaction.
 void abort(long waitFor)
          Abort the transaction, waiting for participants to be notified of the decision.
 void commit()
          Commit the transaction.
 void commit(long waitFor)
          Commit the transaction, waiting for participants to be notified of the decision.
static ServerTransaction create(TransactionManager mgr, long id, long lease)
           
 ServerTransaction createCopy()
           
protected  ServerTransaction createInstance()
          Creates an instance of this class for cloning using the createCopy() method.
 boolean equals(Object other)
          Two instances are equal if they have the same transaction manager and the same transaction id.
 long getLease()
           
 TransactionParticipantDataImpl getMetaData()
           
 int getState()
          Returns the current state of the transaction.
 int hashCode()
           
protected  void initEmbedded()
           
 boolean isEmbeddedMgrInProxy()
          is the xtn manager an embedded proxy-side one ?
 boolean isEmbeddedMgrProxySideInstance()
           
 boolean isNested()
          Return true if the transaction has a parent, false if the transaction is top level.
 boolean isXid()
           
 void join(TransactionParticipant part, long crashCount)
          Join the transaction.
 void join(TransactionParticipant part, long crashCount, int partitionId, String clusterName)
           
protected  void join(TransactionParticipant part, long crashCount, int partitionId, String clusterName, Object proxy)
           
 void joinIfNeededAndEmbedded(TransactionParticipant participant)
          Deprecated. 
 boolean joinIfNeededAndEmbedded(TransactionParticipant participant, int partitionId, String clusterName, Object proxy)
           
 boolean needParticipantsJoin()
          returns true if this the txn participants need to join it in contrary to a xtn which the participants are known prior to txn propagation
 void readExternal(ObjectInput in)
           
 void readFromSwap(ObjectInput in)
           
 void setEmbeddedMgrProxySideInstance(boolean value)
           
 void setLease(long lease)
           
 void setMetaData(TransactionParticipantDataImpl metaData)
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 void writeToSwap(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mgr

public ExtendedTransactionManager mgr
The transaction manager.


id

public long id
The transaction id.


EMBEDDED_CRASH_COUNT

public static final long EMBEDDED_CRASH_COUNT
See Also:
Constant Field Values
Constructor Detail

ServerTransaction

public ServerTransaction()
Do not use, required for externalizable


ServerTransaction

public ServerTransaction(TransactionManager mgr,
                         long id,
                         long lease)
Simple constructor. Clients should not call this directly, but should instead use TransactionFactory.

Parameters:
mgr - the manager for this transaction
id - the transaction id
lease - the lease of the transaction.

ServerTransaction

public ServerTransaction(TransactionManager mgr,
                         long id)

ServerTransaction

public ServerTransaction(TransactionManager mgr,
                         long id,
                         TransactionParticipantDataImpl metaData)
Method Detail

create

public static ServerTransaction create(TransactionManager mgr,
                                       long id,
                                       long lease)
                                throws RemoteException
Throws:
RemoteException

initEmbedded

protected void initEmbedded()
                     throws RemoteException
Throws:
RemoteException

getLease

public long getLease()

setLease

public void setLease(long lease)

equals

public boolean equals(Object other)
Two instances are equal if they have the same transaction manager and the same transaction id.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

commit

public void commit()
            throws UnknownTransactionException,
                   CannotCommitException,
                   RemoteException
Description copied from interface: Transaction
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.

Specified by:
commit in interface Transaction
Throws:
UnknownTransactionException - if the transaction is unknown to the manager. This may be because the transaction ID was incorrect, or because the transaction has proceeded to cleanup due to an earlier commit or abort, and has been forgotten.
CannotCommitException - if the transaction reaches the ABORTED state, or is known to have previously reached that state due to an earlier commit or abort.
RemoteException - if a communication error occurs.

commit

public void commit(long waitFor)
            throws UnknownTransactionException,
                   CannotCommitException,
                   TimeoutExpiredException,
                   RemoteException
Description copied from interface: Transaction
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.

Specified by:
commit in interface Transaction
Parameters:
waitFor - timeout to wait, from the start of the call until all participants have been notified of the transaction manager's decision
Throws:
UnknownTransactionException - if the transaction is unknown to the manager. This may be because the transaction ID was incorrect, or because the transaction has proceeded to cleanup due to an earlier commit or abort, and has been forgotten.
CannotCommitException - if the transaction reaches the ABORTED state, or is known to have previously reached that state due to an earlier commit or abort.
TimeoutExpiredException - if the timeout expires before all participants have been notified.
RemoteException - if a communication error occurs.

abort

public void abort()
           throws UnknownTransactionException,
                  CannotAbortException,
                  RemoteException
Description copied from interface: Transaction
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.

Specified by:
abort in interface Transaction
Throws:
UnknownTransactionException - if the transaction is unknown to the manager. This may be because the transaction ID was incorrect, or because the transaction has proceeded to cleanup due to an earlier commit or abort, and has been forgotten.
CannotAbortException - if the transaction is known to have previously reached the COMMITTED state due to an earlier commit.
RemoteException - if a communication error occurs.

abort

public void abort(long waitFor)
           throws UnknownTransactionException,
                  CannotAbortException,
                  TimeoutExpiredException,
                  RemoteException
Description copied from interface: Transaction
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.

Specified by:
abort in interface Transaction
Parameters:
waitFor - timeout to wait, from the start of the call until all participants have been notified of the transaction manager's decision.
Throws:
UnknownTransactionException - if the transaction is unknown to the manager. This may be because the transaction ID was incorrect, or because the transaction has proceeded to cleanup due to an earlier commit or abort, and has been forgotten.
CannotAbortException - if the transaction is known to have previously reached the COMMITTED state due to an earlier commit.
TimeoutExpiredException - if the timeout expires before all participants have been notified.
RemoteException - if a communication error occurs.

join

public void join(TransactionParticipant part,
                 long crashCount)
          throws UnknownTransactionException,
                 CannotJoinException,
                 CrashCountException,
                 RemoteException
Join the transaction. 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:
part - the participant joining the transaction
crashCount - the participant's current crash count
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.
CannotJoinException - if the transaction is known to the manager but is no longer active.
CrashCountException - if the crash count provided for the participant differs from the crash count in a previous invocation of the same pairing of participant and transaction
RemoteException - if there is a communication error

join

protected void join(TransactionParticipant part,
                    long crashCount,
                    int partitionId,
                    String clusterName,
                    Object proxy)
             throws UnknownTransactionException,
                    CannotJoinException,
                    CrashCountException,
                    RemoteException
Throws:
UnknownTransactionException
CannotJoinException
CrashCountException
RemoteException

join

public void join(TransactionParticipant part,
                 long crashCount,
                 int partitionId,
                 String clusterName)
          throws UnknownTransactionException,
                 CannotJoinException,
                 CrashCountException,
                 RemoteException
Throws:
UnknownTransactionException
CannotJoinException
CrashCountException
RemoteException

getState

public int getState()
             throws UnknownTransactionException,
                    RemoteException
Returns the current state of the transaction. The returned state can be any of the TransactionConstants values.

Returns:
an int representing the state of the transaction
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:
TransactionConstants

isNested

public boolean isNested()
Return true if the transaction has a parent, false if the transaction is top level.

Returns:
true if the transaction has a parent, false if the transaction is top level.

getMetaData

public TransactionParticipantDataImpl getMetaData()
Returns:
the metaData

setMetaData

public void setMetaData(TransactionParticipantDataImpl metaData)
Parameters:
metaData - the metaData to set

isEmbeddedMgrInProxy

public boolean isEmbeddedMgrInProxy()
Description copied from interface: ManagedTransaction
is the xtn manager an embedded proxy-side one ?

Specified by:
isEmbeddedMgrInProxy in interface ManagedTransaction
Returns:
true if the manager is an embedded mngr

isEmbeddedMgrProxySideInstance

public boolean isEmbeddedMgrProxySideInstance()

setEmbeddedMgrProxySideInstance

public void setEmbeddedMgrProxySideInstance(boolean value)

needParticipantsJoin

public boolean needParticipantsJoin()
                             throws RemoteException
returns true if this the txn participants need to join it in contrary to a xtn which the participants are known prior to txn propagation

Specified by:
needParticipantsJoin in interface ManagedTransaction
Returns:
true if its a the xtn mgr requires the txn participants to join
Throws:
RemoteException

isXid

public boolean isXid()

createInstance

protected ServerTransaction createInstance()
Creates an instance of this class for cloning using the createCopy() method.


createCopy

public ServerTransaction createCopy()

joinIfNeededAndEmbedded

@Deprecated
public void joinIfNeededAndEmbedded(TransactionParticipant participant)
                             throws UnknownTransactionException,
                                    CannotJoinException,
                                    CrashCountException,
                                    RemoteException
Deprecated. 

Throws:
UnknownTransactionException
CannotJoinException
CrashCountException
RemoteException

joinIfNeededAndEmbedded

public boolean joinIfNeededAndEmbedded(TransactionParticipant participant,
                                       int partitionId,
                                       String clusterName,
                                       Object proxy)
                                throws UnknownTransactionException,
                                       CannotJoinException,
                                       CrashCountException,
                                       RemoteException
Throws:
UnknownTransactionException
CannotJoinException
CrashCountException
RemoteException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeToSwap

public void writeToSwap(ObjectOutput out)
                 throws IOException
Specified by:
writeToSwap in interface com.gigaspaces.internal.server.space.redolog.storage.bytebuffer.ISwapExternalizable
Throws:
IOException

readFromSwap

public void readFromSwap(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readFromSwap in interface com.gigaspaces.internal.server.space.redolog.storage.bytebuffer.ISwapExternalizable
Throws:
IOException
ClassNotFoundException

GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.