com.atomikos.icatch.trmi
Class TrmiTransactionManager

java.lang.Object
  extended by com.atomikos.icatch.imp.BaseTransactionManager
      extended by com.atomikos.icatch.trmi.TrmiTransactionManager
All Implemented Interfaces:
CompositeTransactionManager, ExportingTransactionManager, ImportingTransactionManager, SubTxAwareParticipant, CompositeTransactionServer, ParticipantServer, RecoveryServer, Serializable, Remote

public final class TrmiTransactionManager
extends BaseTransactionManager
implements CompositeTransactionServer, ParticipantServer, RecoveryServer, Remote, ImportingTransactionManager, ExportingTransactionManager

A transaction manager implementation for RMI-based composite systems.

See Also:
Serialized Form

Constructor Summary
TrmiTransactionManager(boolean trustClientTM, StateRecoveryManager srecmgr, String jndiName, String outputDirPath, long maxTimeout, int maxActives, boolean threaded2PC)
          Create a new instance that listens on the given name.
 
Method Summary
 void addExtent(Extent extent)
          Should be called after call returns successfully: adds the extent of the call to the current transaction.
 com.atomikos.icatch.trmi.RecoveryCoordinatorProxy addParticipant(Participant participantproxy, String txid)
          Add a new participant to the transaction of the given tid.
 void addSubTxAwareParticipant(SubTxAwareParticipant subtxaware, String txid)
          Add a subtx aware participant to the given tx.
 HeuristicMessage[] commit(String root)
          Commit the participant of the given root, after prepare was sent.
 HeuristicMessage[] commitOnePhase(String root, int siblings, Dictionary cascadeList)
          Perform one-phase commit for the given root.
protected  CompositeTransaction createProxy(CompositeTransaction current)
           
 boolean equals(Object o)
           
 void forget(String root)
          Forget all about a given root.
 Propagation getPropagation()
          Gets the propagation info of the transaction for the calling thread.
 int hashCode()
           
 CompositeTransaction importTransaction(Propagation propagation, boolean orphancheck, boolean heur_commit)
          Imports the transaction propagation obtained from an incoming request.
 void init(Properties properties)
          Should be called as first method, to initialize the internal state.
 int prepare(String root, int siblings, Dictionary cascadelist)
          Prepare the participant of the given root.
 Boolean replayCompletion(String root, Participant participant)
          Replay completion for given root, on given participant.
 HeuristicMessage[] rollback(String root)
          Rollback the participant for the given root.
 void shutdown(boolean force)
          Shuts down the server.
 Extent terminated(boolean commit)
          Signals that the incoming request is done processing, in order to terminate the transaction context for the calling thread.
 
Methods inherited from class com.atomikos.icatch.imp.BaseTransactionManager
committed, createCompositeTransaction, getCompositeTransaction, getCompositeTransaction, getParticipant, init, recreateCompositeTransaction, resume, rolledback, startlistening, suspend
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrmiTransactionManager

public TrmiTransactionManager(boolean trustClientTM,
                              StateRecoveryManager srecmgr,
                              String jndiName,
                              String outputDirPath,
                              long maxTimeout,
                              int maxActives,
                              boolean threaded2PC)
                       throws UnknownHostException
Create a new instance that listens on the given name.

Parameters:
trustClientTM - If true, then a forget() on behalf of a remote client TM will be executed. This means that problem cases of 2PC will disappear from the log, and should be used with great care! The advantage of this is less administration on intranet clusters.
srecmgr - The state recovery manager to use.
jndiName - The unique jndi name to listen on. Max BYTE length is 64!
console - For messages from system.
outputDirPath - The output directory path (including ending slash) where the server can write its files.
maxTimeout - The max timeout for new or imported txs.
maxActives - The max no of active txs, or negative if no such number.
threaded2PC - Whether commit should be multi-threaded or not.
Throws:
UnknownHostException - If local hostIP can not be found.
Method Detail

init

public void init(Properties properties)
          throws SysException
Should be called as first method, to initialize the internal state. This method first exports the object to RMI. Then a binding is done into JNDI.

Parameters:
properties - The properties.
Throws:
SysException

createProxy

protected CompositeTransaction createProxy(CompositeTransaction current)
                                    throws SysException
Throws:
SysException

addExtent

public void addExtent(Extent extent)
               throws SysException,
                      RollbackException
Description copied from interface: ExportingTransactionManager
Should be called after call returns successfully: adds the extent of the call to the current transaction. If a remote call has failed, this method should NOT be called.

Specified by:
addExtent in interface ExportingTransactionManager
Parameters:
extent - The extent of the call.
Throws:
SysException - On failure.
RollbackException - If the current transaction has already rolled back.
See Also:
ExportingTransactionManager

terminated

public Extent terminated(boolean commit)
                  throws SysException,
                         RollbackException
Description copied from interface: ImportingTransactionManager
Signals that the incoming request is done processing, in order to terminate the transaction context for the calling thread.

Specified by:
terminated in interface ImportingTransactionManager
Parameters:
commit - True if the invocation had no errors: commit the local transaction but make its final outcome subject to the request's commit/rollback.
Returns:
Extent The extent to return to remote client.
Throws:
SysException
RollbackException - If no transaction exists, e.g. if it has been rolled back already.
See Also:
ImportingTransactionManager

prepare

public int prepare(String root,
                   int siblings,
                   Dictionary cascadelist)
            throws RollbackException,
                   HeurHazardException,
                   HeurMixedException,
                   SysException,
                   RemoteException
Description copied from interface: ParticipantServer
Prepare the participant of the given root.

Specified by:
prepare in interface ParticipantServer
Parameters:
root - The root String of the participant.
siblings - The count of siblings for the given participant.
cascadelist - The list of participants to cascade to, if any.
Throws:
RollbackException
HeurHazardException
HeurMixedException
SysException
RemoteException
See Also:
ParticipantServer.

commit

public HeuristicMessage[] commit(String root)
                          throws HeurRollbackException,
                                 HeurHazardException,
                                 HeurMixedException,
                                 RollbackException,
                                 SysException,
                                 RemoteException
Description copied from interface: ParticipantServer
Commit the participant of the given root, after prepare was sent.

Specified by:
commit in interface ParticipantServer
Parameters:
root - The String of the given root.
Throws:
HeurRollbackException
HeurHazardException
HeurMixedException
RollbackException
SysException
RemoteException
See Also:
ParticipantServer.

commitOnePhase

public HeuristicMessage[] commitOnePhase(String root,
                                         int siblings,
                                         Dictionary cascadeList)
                                  throws HeurRollbackException,
                                         HeurHazardException,
                                         HeurMixedException,
                                         RollbackException,
                                         SysException,
                                         RemoteException
Description copied from interface: ParticipantServer
Perform one-phase commit for the given root.

Specified by:
commitOnePhase in interface ParticipantServer
Parameters:
root - The root id.
siblings - The count of siblings for the given participant.
cascadeList - The info needed for orphan detection.
Throws:
HeurRollbackException
HeurHazardException
HeurMixedException
RollbackException
SysException
RemoteException
See Also:
ParticipantServer.

rollback

public HeuristicMessage[] rollback(String root)
                            throws HeurCommitException,
                                   HeurMixedException,
                                   HeurHazardException,
                                   SysException,
                                   RemoteException
Description copied from interface: ParticipantServer
Rollback the participant for the given root.

Specified by:
rollback in interface ParticipantServer
Parameters:
root - The given root.
Throws:
HeurCommitException
HeurMixedException
HeurHazardException
SysException
RemoteException
See Also:
ParticipantServer

forget

public void forget(String root)
            throws SysException,
                   RemoteException
Description copied from interface: ParticipantServer
Forget all about a given root.

Specified by:
forget in interface ParticipantServer
Parameters:
root - The root to forget about.
Throws:
SysException
RemoteException
See Also:
ParticipantServer.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

addSubTxAwareParticipant

public void addSubTxAwareParticipant(SubTxAwareParticipant subtxaware,
                                     String txid)
                              throws SysException,
                                     IllegalStateException,
                                     RemoteException
Description copied from interface: CompositeTransactionServer
Add a subtx aware participant to the given tx.

Specified by:
addSubTxAwareParticipant in interface CompositeTransactionServer
Parameters:
subtxaware - The participant to add, will be notified on end().
txid - The ID of the transaction to which the participant must be added.
Throws:
SysException - Unexpected error.
IllegalStateException - If txid is no longer an active tx.
RemoteException
See Also:
CompositeTransactionServer

addParticipant

public com.atomikos.icatch.trmi.RecoveryCoordinatorProxy addParticipant(Participant participantproxy,
                                                                        String txid)
                                                                 throws SysException,
                                                                        IllegalStateException,
                                                                        RemoteException
Description copied from interface: CompositeTransactionServer
Add a new participant to the transaction of the given tid.

Specified by:
addParticipant in interface CompositeTransactionServer
Returns:
RecoveryCoordinatorProxy Whom to ask for indoubt timeout resolution.
Throws:
SysException - Unexpected.
IllegalStateException - Illegal state.
RemoteException

replayCompletion

public Boolean replayCompletion(String root,
                                Participant participant)
                         throws RemoteException,
                                SysException
Description copied from interface: RecoveryServer
Replay completion for given root, on given participant.

Specified by:
replayCompletion in interface RecoveryServer
Parameters:
root - The root.
participant - The participant.
Throws:
RemoteException - On remote failure.
SysException

shutdown

public void shutdown(boolean force)
              throws SysException,
                     IllegalStateException
Shuts down the server.

Overrides:
shutdown in class BaseTransactionManager
Parameters:
force - If true, possibly indoubt txs will not be taken into account.
Throws:
SysException - On failure.
IllegalStateException - If active txs and not force.

importTransaction

public CompositeTransaction importTransaction(Propagation propagation,
                                              boolean orphancheck,
                                              boolean heur_commit)
                                       throws SysException
Description copied from interface: ImportingTransactionManager
Imports the transaction propagation obtained from an incoming request.

Specified by:
importTransaction in interface ImportingTransactionManager
Parameters:
propagation - The ancestor information.
orphancheck - True if orphans are to be checked.
heur_commit - True if heuristic means commit.
Returns:
CompositeTransaction The locally created transaction instance that takes part in the global commit/rollback. This instance will also be mapped to the calling thread.
Throws:
SysException

getPropagation

public Propagation getPropagation()
                           throws SysException,
                                  RollbackException
Description copied from interface: ExportingTransactionManager
Gets the propagation info of the transaction for the calling thread. Should be called before doing the remote call.

Specified by:
getPropagation in interface ExportingTransactionManager
Returns:
Propagation The propagation for the current thread.
Throws:
SysException
RollbackException - If no such transaction exists, e.g. after a prior rollback.


Copyright © 2012. All Rights Reserved.