com.atomikos.icatch.imp
Class TransactionServiceImp

java.lang.Object
  extended by com.atomikos.icatch.imp.TransactionServiceImp
All Implemented Interfaces:
FSMEnterListener<TxState>, RecoveryService, SubTxAwareParticipant, TransactionService, Serializable, EventListener

public class TransactionServiceImp
extends Object
implements TransactionService, FSMEnterListener<TxState>, SubTxAwareParticipant, RecoveryService

General implementation of Transaction Service.

See Also:
Serialized Form

Constructor Summary
TransactionServiceImp(String name, StateRecoveryManager recoverymanager, UniqueIdMgr tidmgr, long maxtimeout, boolean checkorphans, int maxActives, boolean single_threaded_2pc)
          Create a new instance, with orphan checking set.
TransactionServiceImp(String name, StateRecoveryManager recoverymanager, UniqueIdMgr tidmgr, long maxtimeout, int maxActives, boolean single_threaded_2pc)
          Create a new instance, with orphan checking set.
 
Method Summary
 void addTSListener(TSListener listener)
           
 void committed(CompositeTransaction tx)
          Called if a tx is ended successfully.
 CompositeTransaction createCompositeTransaction(long timeout)
           
protected  String createTid()
          Create a new tid.
 void entered(FSMEnterEvent<TxState> event)
           
 void finalize()
           
 CompositeCoordinator getCompositeCoordinator(String root)
           
 CompositeTransaction getCompositeTransaction(String tid)
           
protected  Object getLatch(String root)
          Get an object to lock for the given root.
 LogControl getLogControl()
          Get a LogControl for the service.
 String getName()
           
 Participant getParticipant(String root)
           
protected  StateRecoveryManager getStateRecoveryManager()
          Get the state recovery manager.
 RecoveryCoordinator getSuperiorRecoveryCoordinator(String root)
           
 void init(Properties properties)
           
 void recover()
           
protected  void recoverCoordinators()
          Recover instances from a given recovery manager.
 CompositeTransaction recreateCompositeTransaction(Propagation context, boolean orphancheck, boolean heur_commit)
           
 void removeTSListener(TSListener listener)
           
 void rolledback(CompositeTransaction tx)
          Called if a tx is ended with failure.
 void shutdown(boolean force)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionServiceImp

public TransactionServiceImp(String name,
                             StateRecoveryManager recoverymanager,
                             UniqueIdMgr tidmgr,
                             long maxtimeout,
                             int maxActives,
                             boolean single_threaded_2pc)
Create a new instance, with orphan checking set.

Parameters:
name - The unique name of this TM.
recoverymanager - The recovery manager to use.
tidmgr - The String manager to use.
console - The console to use. Null if none.
maxtimeout - The max timeout for new or imported txs.
maxActives - The max number of active txs, or negative if unlimited.
single_threaded_2pc - Whether 2PC commit should happen in the same thread that started the tx.

TransactionServiceImp

public TransactionServiceImp(String name,
                             StateRecoveryManager recoverymanager,
                             UniqueIdMgr tidmgr,
                             long maxtimeout,
                             boolean checkorphans,
                             int maxActives,
                             boolean single_threaded_2pc)
Create a new instance, with orphan checking set.

Parameters:
name - The unique name of this TM.
recoverymanager - The recovery manager to use.
tidmgr - The String manager to use.
console - The console to use. Null if none.
maxtimeout - The max timeout for new or imported txs.
checkorphans - If false, orphan checking is disabled
maxActives - The max number of active txs, or negative if unlimited. even for creation requests that ask for checks. This mode may be needed for being compatible with certain configurations that do not support orphan detection.
single_threaded_2pc - Whether 2PC commit should happen in the same thread that started the tx.
Method Detail

getLatch

protected Object getLatch(String root)
Get an object to lock for the given root. To increase concurrency and still provide atomic operations within the scope of one root.

Returns:
Object The object to lock for the given root.

createTid

protected String createTid()
                    throws SysException
Create a new tid.

Returns:
String The newly created and unique identifier.
Throws:
SysException

getStateRecoveryManager

protected StateRecoveryManager getStateRecoveryManager()
Get the state recovery manager.

Returns:
StateRecoveryManager The recovery manager.

recoverCoordinators

protected void recoverCoordinators()
                            throws SysException
Recover instances from a given recovery manager.

Throws:
SysException - For unexpected failure.

getName

public String getName()
Specified by:
getName in interface RecoveryService

recover

public void recover()
Specified by:
recover in interface RecoveryService
See Also:
RecoveryService

getLogControl

public LogControl getLogControl()
Get a LogControl for the service.

Returns:
LogControl The instance.

getCompositeCoordinator

public CompositeCoordinator getCompositeCoordinator(String root)
                                             throws SysException
Specified by:
getCompositeCoordinator in interface TransactionService
Throws:
SysException
See Also:
TransactionService

addTSListener

public void addTSListener(TSListener listener)
                   throws IllegalStateException
Specified by:
addTSListener in interface TransactionService
Throws:
IllegalStateException
See Also:
TransactionService

removeTSListener

public void removeTSListener(TSListener listener)
Specified by:
removeTSListener in interface TransactionService
See Also:
TransactionService

init

public void init(Properties properties)
          throws SysException
Specified by:
init in interface TransactionService
Throws:
SysException
See Also:
TransactionService

getParticipant

public Participant getParticipant(String root)
                           throws SysException
Specified by:
getParticipant in interface TransactionService
Throws:
SysException
See Also:
TransactionService

entered

public void entered(FSMEnterEvent<TxState> event)
Specified by:
entered in interface FSMEnterListener<TxState>
See Also:
FSMEnterListener.

committed

public void committed(CompositeTransaction tx)
Called if a tx is ended successfully. In order to remove the tx from the mapping.

Specified by:
committed in interface SubTxAwareParticipant
See Also:
SubTxAwareParticipant

rolledback

public void rolledback(CompositeTransaction tx)
Called if a tx is ended with failure. In order to remove tx from mapping.

Specified by:
rolledback in interface SubTxAwareParticipant
See Also:
SubTxAwareParticipant

getCompositeTransaction

public CompositeTransaction getCompositeTransaction(String tid)
Specified by:
getCompositeTransaction in interface TransactionService
See Also:
TransactionService

recreateCompositeTransaction

public CompositeTransaction recreateCompositeTransaction(Propagation context,
                                                         boolean orphancheck,
                                                         boolean heur_commit)
                                                  throws SysException
Specified by:
recreateCompositeTransaction in interface TransactionService
Throws:
SysException
See Also:
TransactionService

shutdown

public void shutdown(boolean force)
              throws SysException,
                     IllegalStateException
Specified by:
shutdown in interface TransactionService
Throws:
SysException
IllegalStateException
See Also:
TransactionService

finalize

public void finalize()
              throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

getSuperiorRecoveryCoordinator

public RecoveryCoordinator getSuperiorRecoveryCoordinator(String root)
Specified by:
getSuperiorRecoveryCoordinator in interface TransactionService
See Also:
TransactionService.getSuperiorRecoveryCoordinator(java.lang.String)

createCompositeTransaction

public CompositeTransaction createCompositeTransaction(long timeout)
                                                throws SysException
Specified by:
createCompositeTransaction in interface TransactionService
Throws:
SysException


Copyright © 2014. All Rights Reserved.