Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.atomikos.icatch.imp
Class TransactionServiceImp

    java.lang.Object
      com.atomikos.icatch.imp.TransactionServiceImp

All Implemented Interfaces:
  FSMEnterListener, RecoveryService, SubTxAwareParticipant, TransactionService, Serializable, EventListener

    public class TransactionServiceImp

extends Object
implements TransactionService, FSMEnterListener, SubTxAwareParticipant, RecoveryService

General implementation of Transaction Service.

See Also:
  Serialized Form

Constructor Summary
`TransactionServiceImp(String name, StateRecoveryManager recoverymanager, UniqueIdMgr tidmgr, Console console, 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, Console console, long maxtimeout, int maxActives, boolean single_threaded_2pc)` Create a new instance, with orphan checking set.

Method Summary
`void` | `addTSListener(TSListener listener)` Adds a listener to the transaction service.
`void` | `committed(CompositeTransaction tx)` Called if a tx is ended successfully.
`CompositeTransaction` | `createCompositeTransaction(long timeout)` Start a new transaction.
`protected String` | `createTid()` Create a new tid.
`void` | `entered(FSMEnterEvent event)` Called when the FSM has entered a new state.
`void` | `finalize()`
`CompositeCoordinator` | `getCompositeCoordinator(String root)` Gets a composite coordinator for the given root.
`CompositeTransaction` | `getCompositeTransaction(String tid)` Get the composite transaction with the given 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()` Get the transaction service's unique name.
`Participant` | `getParticipant(String root)` Get a participant for the given root.
`protected StateRecoveryManager` | `getStateRecoveryManager()` Get the state recovery manager.
`RecoveryCoordinator` | `getSuperiorRecoveryCoordinator(String root)` Gets the superior recovery coordinator for a given root.
`void` | `init(Properties properties)` Initialize TM, and recover.
`void` | `recover()` Ask the TM to recover.
`protected void` | `recoverCoordinators()` Recover instances from a given recovery manager.
`CompositeTransaction` | `recreateCompositeTransaction(Propagation context, boolean orphancheck, boolean heur_commit)` Recreate a composite transaction based on an imported context.
`void` | `removeTSListener(TSListener listener)` Removes a listener from the transaction service.
`void` | `rolledback(CompositeTransaction tx)` Called if a tx is ended with failure.
`void` | `shutdown(boolean force)` Shut down the server in a clean way.

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,
                                 Console console,
                                 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,
                                 Console console,
                                 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()

  Description copied from interface: `RecoveryService`
  Get the transaction service's unique name. Resources can use this name to determine what resource transactions need to be considered for recovery by this transaction service.

  Specified by:
    `getName` in interface `RecoveryService`
  Returns:
    String The name of the TM.

### recover

    public void recover()

  Description copied from interface: `RecoveryService`
  Ask the TM to recover. Resources should call this method whenever recovery is needed. The earliest time at which resources can call this method is when setRecoveryService is called on the resource. Note: resources that are registered before the TM starts up will not need to call this method. On the other hand, resources that are registered when the transaction service is already running should use this method to trigger recovery. It is up to the implementation of the resource to determine whether this is desirable.

  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

  Description copied from interface: `TransactionService`
  Gets a composite coordinator for the given root. Needed to allow TM to swap out instances after heuristic termination. If a commit, abort, forget or replay request comes in, this method should be called first to revive the instance.

  Specified by:
    `getCompositeCoordinator` in interface `TransactionService`
  Parameters:
    `root` - The root in case.
  Returns:
    CoordinatorImp The composite coordinator for root.
  Throws:
    `SysException` - If not found.
  See Also:
    `TransactionService`

### addTSListener

    public void addTSListener(TSListener listener)
                       throws IllegalStateException

  Description copied from interface: `TransactionService`
  Adds a listener to the transaction service. This method should be called before init! If called afterwards, only the init (false) callback will happen in the listener.

  Specified by:
    `addTSListener` in interface `TransactionService`
  Parameters:
    `listener` - The listener.
  Throws:
    `IllegalStateException`
  See Also:
    `TransactionService`

### removeTSListener

    public void removeTSListener(TSListener listener)

  Description copied from interface: `TransactionService`
  Removes a listener from the transaction service.

  Specified by:
    `removeTSListener` in interface `TransactionService`
  Parameters:
    `listener` - The listener.
  See Also:
    `TransactionService`

### init

    public void init(Properties properties)
              throws SysException

  Description copied from interface: `TransactionService`
  Initialize TM, and recover. Should be first method called.

  Specified by:
    `init` in interface `TransactionService`
  Parameters:
    `properties` - The properties used to initialize the system.
  Throws:
    `SysException` - Unexpected failure.
  See Also:
    `TransactionService`

### getParticipant

    public Participant getParticipant(String root)
                               throws SysException

  Description copied from interface: `TransactionService`
  Get a participant for the given root. This method is for subordinator coordinators: in those cases, a participant role is fulfilled w.r.t. parent coordinators.

  Specified by:
    `getParticipant` in interface `TransactionService`
  Parameters:
    `root` - The root identifier.
  Returns:
    Participant The participant instance.
  Throws:
    `SysException` - On failure, or if the given root is not known.
  See Also:
    `TransactionService`

### entered

    public void entered(FSMEnterEvent event)

  Description copied from interface: `FSMEnterListener`
  Called when the FSM has entered a new state.

  Specified by:
    `entered` in interface `FSMEnterListener`
  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`
  Parameters:
    `tx` - The composite transaction that has terminated locally at its node.
  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)

  Description copied from interface: `TransactionService`
  Get the composite transaction with the given tid.

  Specified by:
    `getCompositeTransaction` in interface `TransactionService`
  Parameters:
    `tid` - The transaction identifier.
  Returns:
    CompositeTransaction The transaction, or null if none.
  See Also:
    `TransactionService`

### recreateCompositeTransaction

    public CompositeTransaction recreateCompositeTransaction(Propagation context,
                                                             boolean orphancheck,
                                                             boolean heur_commit)
                                                      throws SysException

  Description copied from interface: `TransactionService`
  Recreate a composite transaction based on an imported context. Needed by the application's communication layer.

  Specified by:
    `recreateCompositeTransaction` in interface `TransactionService`
  Parameters:
    `context` - The propagationcontext. Any interposition actions should already have taken place, so that the propagation is ready to be used by the local transaction service.
    `orphancheck` - If true, real composite txs are done. If false, OTS like behavior applies.
    `heur_commit` - True for heuristic commit, false for heuristic rollback.
  Returns:
    CompositeTransaction The recreated local instance.
  Throws:
    `SysException` - Failure.
  See Also:
    `TransactionService`

### shutdown

    public void shutdown(boolean force)
                  throws SysException,
                         IllegalStateException

  Description copied from interface: `TransactionService`
  Shut down the server in a clean way.

  Specified by:
    `shutdown` in interface `TransactionService`
  Parameters:
    `force` - If true, shutdown will not wait for possibly indoubt txs to finish. Calling shutdown with force being true implies that shutdown will not fail, but there may be remaining timer threads that stay asleep until there timeouts expire. Such remaining active transactions will NOT be able to finish, because the recovery manager will be shutdown by that time. New transactions will not be allowed.
  Throws:
    `SysException` - For unexpected errors.
    `IllegalStateException` - If active txs exist, and not force.
  See Also:
    `TransactionService`

### finalize

    public void finalize()
                  throws Throwable

  Overrides:
    `finalize` in class `Object`
  Throws:
    `Throwable`

### getSuperiorRecoveryCoordinator

    public RecoveryCoordinator getSuperiorRecoveryCoordinator(String root)

  Description copied from interface: `TransactionService`
  Gets the superior recovery coordinator for a given root. Needed for imported transactions only.

  Specified by:
    `getSuperiorRecoveryCoordinator` in interface `TransactionService`
  Parameters:
    `root` - The root ID
  Returns:
    The recovery coordinator, or null if the root does not exist or if the root was not imported.
  See Also:
    `TransactionService.getSuperiorRecoveryCoordinator(java.lang.String)`

### createCompositeTransaction

    public CompositeTransaction createCompositeTransaction(long timeout)
                                                    throws SysException

  Description copied from interface: `TransactionService`
  Start a new transaction.

  Specified by:
    `createCompositeTransaction` in interface `TransactionService`
  Returns:
    CompositeTransaction The new instance.
  Throws:
    `SysException` - Unexpected error.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012. All Rights Reserved.