com.atomikos.icatch.imp
Class CompositeTransactionImp

java.lang.Object
  extended by com.atomikos.icatch.imp.AbstractCompositeTransaction
      extended by com.atomikos.icatch.imp.CompositeTransactionImp
All Implemented Interfaces:
FSMEnterListener, Stateful, CompositeTransaction, TransactionControl, Serializable, EventListener

public class CompositeTransactionImp
extends AbstractCompositeTransaction
implements TransactionControl, FSMEnterListener

A complete composite transaction implementation for use in LOCAL VM.

See Also:
Serialized Form

Field Summary
protected  CoordinatorImp coordinator_
           
protected  Extent extent_
           
protected  boolean localRoot_
           
protected  TransactionServiceImp txservice_
           
 
Fields inherited from class com.atomikos.icatch.imp.AbstractCompositeTransaction
lineage_, properties_, serial_, tag_, tid_
 
Constructor Summary
CompositeTransactionImp(TransactionServiceImp txservice, Stack lineage, String tid, boolean serial, CoordinatorImp coordinator)
          Constructor.
 
Method Summary
 RecoveryCoordinator addParticipant(Participant participant)
          Add a new participant.
 void addSubTxAwareParticipant(SubTxAwareParticipant subtxaware)
          Register a participant on behalf of a subtransaction, to be notified as soon as the locally finished state is reached.
 void commit()
          Commit the composite transaction.
 CompositeTransaction createSubTransaction()
          Create a subtx for this transaction.
protected  void doCommit()
          Successfully end the composite transaction.
protected  void doRollback()
           
 void entered(FSMEnterEvent event)
          Called when the FSM has entered a new state.
 CompositeCoordinator getCompositeCoordinator()
          Get the coordinator for this tx.
 Extent getExtent()
          Get the extent for the transaction.
 int getLocalSubTxCount()
          Get the number of subtxs that were locally started for this instance.
 Object getState()
          Get the current state.
 CompositeTerminator getTerminator()
          Get a terminator for this tx.
 long getTimeout()
          Get the timeout in ms.
 TransactionControl getTransactionControl()
          Get a control object for this tx.
 boolean isLocal()
          Test if the transaction is a locally started transaction or not.
 void registerSynchronization(Synchronization sync)
          Add a synchronization callback.
 void rollback()
          Rollback the current transaction.
 void setRollbackOnly()
          Marks the transaction so that the only possible termination is rollback.
 void setSerial()
          Set serial mode for root.
 
Methods inherited from class com.atomikos.icatch.imp.AbstractCompositeTransaction
equals, getLineage, getProperties, getProperty, getTid, hashCode, isAncestorOf, isDescendantOf, isRelatedTransaction, isRoot, isSameTransaction, isSerial, setProperty, setTag
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atomikos.icatch.TransactionControl
setTag
 

Field Detail

coordinator_

protected CoordinatorImp coordinator_

txservice_

protected TransactionServiceImp txservice_

extent_

protected Extent extent_

localRoot_

protected boolean localRoot_
Constructor Detail

CompositeTransactionImp

public CompositeTransactionImp(TransactionServiceImp txservice,
                               Stack lineage,
                               String tid,
                               boolean serial,
                               CoordinatorImp coordinator)
                        throws IllegalStateException
Constructor.

Parameters:
txservice - The Transaction Service this is for.
lineage - The ancestor information.
tid - The identifier for this one.
serial - If true, no parallel calls allowed.
coordinator - The coordinator to use.
Throws:
IllegalStateException - If coordinator no longer activatable.
Method Detail

getTransactionControl

public TransactionControl getTransactionControl()
Description copied from interface: CompositeTransaction
Get a control object for this tx.

Specified by:
getTransactionControl in interface CompositeTransaction
Overrides:
getTransactionControl in class AbstractCompositeTransaction
Returns:
TransactionControl a control object.
See Also:
CompositeTransaction.

getLocalSubTxCount

public int getLocalSubTxCount()
Description copied from interface: CompositeTransaction
Get the number of subtxs that were locally started for this instance.

Specified by:
getLocalSubTxCount in interface CompositeTransaction
Specified by:
getLocalSubTxCount in interface TransactionControl
Overrides:
getLocalSubTxCount in class AbstractCompositeTransaction
Returns:
int The number of locally started subtxs.
See Also:
TransactionControl

setSerial

public void setSerial()
               throws IllegalStateException,
                      SysException
Description copied from interface: CompositeTransaction
Set serial mode for root. This only works on the root itself, and can not be undone. After this, no parallel calls are allowed in any descendant.

Specified by:
setSerial in interface CompositeTransaction
Specified by:
setSerial in interface TransactionControl
Overrides:
setSerial in class AbstractCompositeTransaction
Throws:
IllegalStateException - If called for non-root tx.
SysException - For unexpected errors.
See Also:
TransactionControl.

createSubTransaction

public CompositeTransaction createSubTransaction()
                                          throws SysException,
                                                 IllegalStateException
Description copied from interface: CompositeTransaction
Create a subtx for this transaction. For activities, the subtransaction will also be an activity.

Specified by:
createSubTransaction in interface CompositeTransaction
Specified by:
createSubTransaction in interface TransactionControl
Overrides:
createSubTransaction in class AbstractCompositeTransaction
Returns:
CompositeTransaction The subtx.
Throws:
IllegalStateException - If no longer active.
SysException
See Also:
TransactionControl.

addParticipant

public RecoveryCoordinator addParticipant(Participant participant)
                                   throws SysException,
                                          IllegalStateException
Description copied from interface: CompositeTransaction
Add a new participant.

Specified by:
addParticipant in interface CompositeTransaction
Overrides:
addParticipant in class AbstractCompositeTransaction
Parameters:
participant - The participant to add.
Returns:
RecoveryCoordinator Whom to ask for indoubt timeout resolution.
Throws:
SysException - Unexpected.
IllegalStateException - Illegal state.
See Also:
CompositeTransaction

registerSynchronization

public void registerSynchronization(Synchronization sync)
                             throws IllegalStateException,
                                    UnsupportedOperationException,
                                    SysException
Description copied from interface: CompositeTransaction
Add a synchronization callback.

Specified by:
registerSynchronization in interface CompositeTransaction
Overrides:
registerSynchronization in class AbstractCompositeTransaction
Parameters:
sync - The callback object.
Throws:
IllegalStateException - If no tx longer active.
SysException - Unexptected failure.
UnsupportedOperationException
See Also:
CompositeTransaction

addSubTxAwareParticipant

public void addSubTxAwareParticipant(SubTxAwareParticipant subtxaware)
                              throws SysException,
                                     IllegalStateException
Description copied from interface: CompositeTransaction
Register a participant on behalf of a subtransaction, to be notified as soon as the locally finished state is reached. Resources that support lock inheritance can use this feature to be notified whenever a lock should be inherited.

Specified by:
addSubTxAwareParticipant in interface CompositeTransaction
Overrides:
addSubTxAwareParticipant in class AbstractCompositeTransaction
Parameters:
subtxaware - The participant to be notified on local termination.
Throws:
IllegalStateException - If no longer active.
SysException
See Also:
CompositeTransaction

doRollback

protected void doRollback()
                   throws IllegalStateException,
                          SysException
Throws:
IllegalStateException
SysException
See Also:
TransactionControl.

getCompositeCoordinator

public CompositeCoordinator getCompositeCoordinator()
                                             throws SysException
Description copied from interface: CompositeTransaction
Get the coordinator for this tx.

Specified by:
getCompositeCoordinator in interface CompositeTransaction
Overrides:
getCompositeCoordinator in class AbstractCompositeTransaction
Returns:
CompositeCoordinator The composite coordinator instance.
Throws:
SysException - On failure.
See Also:
CompositeTransaction.

isLocal

public boolean isLocal()
Description copied from interface: CompositeTransaction
Test if the transaction is a locally started transaction or not.

Specified by:
isLocal in interface CompositeTransaction
Overrides:
isLocal in class AbstractCompositeTransaction
Returns:
boolean True iff started in the local VM. For imported transactions, this is false.
See Also:
CompositeTransaction.

getTerminator

public CompositeTerminator getTerminator()
Description copied from interface: TransactionControl
Get a terminator for this tx.

Specified by:
getTerminator in interface TransactionControl
Returns:
CompositeTerminator A terminator, null if none.
See Also:
TransactionControl.

doCommit

protected void doCommit()
                 throws SysException,
                        IllegalStateException,
                        RollbackException
Successfully end the composite transaction. Marks it as inactive. Called by Terminator implementation only! NOTE: this does NOT commit the participants, but rather only marks the (sub)transaction as being ELIGIBLE FOR PREPARE IN 2PC.

Throws:
IllegalStateException - If no longer active.
SysException - Unexpected failure.
RollbackException

getTimeout

public long getTimeout()
Description copied from interface: CompositeTransaction
Get the timeout in ms.

Specified by:
getTimeout in interface CompositeTransaction
Specified by:
getTimeout in interface TransactionControl
Overrides:
getTimeout in class AbstractCompositeTransaction
Returns:
long The timeout, in ms, of the tx.
See Also:
TransactionControl

getExtent

public Extent getExtent()
Description copied from interface: CompositeTransaction
Get the extent for the transaction.

Specified by:
getExtent in interface CompositeTransaction
Specified by:
getExtent in interface TransactionControl
Overrides:
getExtent in class AbstractCompositeTransaction
See Also:
TransactionControl.

setRollbackOnly

public void setRollbackOnly()
Description copied from interface: CompositeTransaction
Marks the transaction so that the only possible termination is rollback.

Specified by:
setRollbackOnly in interface CompositeTransaction
Specified by:
setRollbackOnly in interface TransactionControl
Overrides:
setRollbackOnly in class AbstractCompositeTransaction
See Also:
TransactionControl.

commit

public void commit()
            throws HeurRollbackException,
                   HeurMixedException,
                   HeurHazardException,
                   SysException,
                   SecurityException,
                   RollbackException
Description copied from interface: CompositeTransaction
Commit the composite transaction.

Specified by:
commit in interface CompositeTransaction
Overrides:
commit in class AbstractCompositeTransaction
Throws:
HeurRollbackException - On heuristic rollback.
HeurMixedException - On heuristic mixed outcome.
HeurHazardException - In case of heuristic hazard.
SysException - For unexpected failures.
SecurityException - If calling thread does not have right to commit.
RollbackException - If the transaction was rolled back before prepare.
See Also:
CompositeTransaction.commit()

rollback

public void rollback()
              throws IllegalStateException,
                     SysException
Description copied from interface: CompositeTransaction
Rollback the current transaction.

Specified by:
rollback in interface CompositeTransaction
Overrides:
rollback in class AbstractCompositeTransaction
Throws:
IllegalStateException - If prepared or inactive.
SysException - If unexpected error.
See Also:
CompositeTransaction.rollback()

getState

public Object getState()
Description copied from interface: CompositeTransaction
Get the current state.

Specified by:
getState in interface Stateful
Specified by:
getState in interface CompositeTransaction
Overrides:
getState in class AbstractCompositeTransaction
Returns:
The object representing the state.
See Also:
com.atomikos.finitestates.Stateful.

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:
com.atomikos.finitestates.FSMEnterListener#preEnter(com.atomikos.finitestates.FSMEnterEvent)


Copyright © 2011. All Rights Reserved.