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 the local VM.

See Also:
Serialized Form

Field Summary
protected  CoordinatorImp coordinator_
           
protected  Extent extent_
           
protected  boolean noLocalAncestors_
           
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)
           
 void addSubTxAwareParticipant(SubTxAwareParticipant subtxaware)
          Resources that support lock inheritance can use this feature to be notified whenever a lock should be inherited.
 void commit()
          Commits 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 coordinatorTerminatedEvent)
          Called when the FSM has entered a new state.
 CompositeCoordinator getCompositeCoordinator()
           
 Extent getExtent()
          Get the extent for the transaction.
 int getLocalSubTxCount()
          Get the number of subtxs that were locally started for this instance.
 Object getState()
          Gets the current state.
 CompositeTerminator getTerminator()
          Get a terminator for this tx.
 long getTimeout()
          Get the timeout in ms.
 TransactionControl getTransactionControl()
           
 boolean isLocal()
           
 void registerSynchronization(Synchronization sync)
           
 void rollback()
          Rollback of the current transaction.
 void setRollbackOnly()
          Marks the transaction so that the only possible termination is rollback.
 void setSerial()
          Sets the serial mode.
 
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_

noLocalAncestors_

protected boolean noLocalAncestors_
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()
Specified by:
getTransactionControl in interface CompositeTransaction
Overrides:
getTransactionControl in class AbstractCompositeTransaction
See Also:
CompositeTransaction.

getLocalSubTxCount

public int getLocalSubTxCount()
Description copied from interface: TransactionControl
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
Sets the serial mode. 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: TransactionControl
Create a subtx for this transaction.

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
Specified by:
addParticipant in interface CompositeTransaction
Overrides:
addParticipant in class AbstractCompositeTransaction
Returns:
RecoveryCoordinator Whom to ask for indoubt timeout resolution.
Throws:
SysException
IllegalStateException
See Also:
CompositeTransaction

registerSynchronization

public void registerSynchronization(Synchronization sync)
                             throws IllegalStateException,
                                    UnsupportedOperationException,
                                    SysException
Specified by:
registerSynchronization in interface CompositeTransaction
Overrides:
registerSynchronization in class AbstractCompositeTransaction
Throws:
IllegalStateException
SysException
UnsupportedOperationException
See Also:
CompositeTransaction

addSubTxAwareParticipant

public void addSubTxAwareParticipant(SubTxAwareParticipant subtxaware)
                              throws SysException,
                                     IllegalStateException
Description copied from interface: CompositeTransaction
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
Throws:
SysException
IllegalStateException
See Also:
CompositeTransaction

doRollback

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

getCompositeCoordinator

public CompositeCoordinator getCompositeCoordinator()
                                             throws SysException
Specified by:
getCompositeCoordinator in interface CompositeTransaction
Overrides:
getCompositeCoordinator in class AbstractCompositeTransaction
Returns:
CompositeCoordinator
Throws:
SysException
See Also:
CompositeTransaction.

isLocal

public boolean isLocal()
Specified by:
isLocal in interface CompositeTransaction
Overrides:
isLocal in class AbstractCompositeTransaction
Returns:
boolean True if 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: TransactionControl
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 transaction timeout in millis.
See Also:
TransactionControl

getExtent

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

Specified by:
getExtent in interface CompositeTransaction
Specified by:
getExtent in interface TransactionControl
Overrides:
getExtent in class AbstractCompositeTransaction
Returns:
The extent.
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
Commits 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 of 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
Gets 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 coordinatorTerminatedEvent)
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 © 2012. All Rights Reserved.