com.atomikos.icatch.imp
Class CoordinatorImp

java.lang.Object
  extended by com.atomikos.icatch.imp.CoordinatorImp
All Implemented Interfaces:
FSMEnterListener, FSMPreEnterEventSource, FSMPreEnterListener, FSMTransitionListener, Stateful, CompositeCoordinator, Participant, RecoveryCoordinator, RecoverableCoordinator, AlarmTimerListener, Serializable, EventListener

public class CoordinatorImp
extends Object
implements CompositeCoordinator, Participant, RecoveryCoordinator, RecoverableCoordinator, AlarmTimerListener, Stateful, FSMPreEnterListener, FSMTransitionListener, FSMEnterListener

All things related to termination logic.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.atomikos.icatch.Participant
READ_ONLY
 
Constructor Summary
  CoordinatorImp()
          No argument constructor as required by Recoverable interface.
protected CoordinatorImp(String root, boolean heuristic_commit, boolean checkorphans)
          Constructor for testing only.
protected CoordinatorImp(String root, RecoveryCoordinator coord, boolean heuristic_commit, long timeout, boolean checkorphans, boolean single_threaded_2pc)
          Constructor.
 
Method Summary
 void addFSMPreEnterListener(FSMPreEnterListener l, TxState state)
           
 void alarm(AlarmTimer timer)
           
 void commit(boolean onePhase)
           
protected  void dispose()
           
 void entered(FSMEnterEvent e)
          Called when the FSM has entered a new state.
 void forget()
           
 String getCoordinatorId()
           
 CoordinatorLogEntry getCoordinatorLogEntry()
           
 CoordinatorLogEntry getCoordinatorLogEntry(TxState state)
           
 Object getId()
           
 Participant getParticipant()
           
 Collection<ParticipantLogEntry> getParticipantLogEntries()
           
 Vector<Participant> getParticipants()
           
 RecoveryCoordinator getRecoveryCoordinator()
           
 String getResourceName()
           
 TxState getState()
           
 TxState getStateWithTwoPhaseCommitDecision()
           
protected  long getTimeOut()
           
 String getURI()
           
protected  void incLocalSiblingCount()
          Called when a tx import is being done.
 boolean isCommitted()
          Tests if the transaction was committed or not.
 boolean isRecoverable()
           
 void preEnter(FSMEnterEvent event)
          Called BEFORE the FSM enters the new state, so that the callee is sure that nobody has seen the new state yet.
 int prepare()
           
 Boolean replayCompletion(Participant participant)
           
 void rollback()
           
 void setCascadeList(Map<String,Integer> allParticipants)
           
 void setGlobalSiblingCount(int count)
           
protected  void terminate(boolean commit)
          Terminate the work, on behalf of Terminator.
 void transitionPerformed(FSMTransitionEvent e)
          A method to be called AFTER the specified transition is done.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoordinatorImp

protected CoordinatorImp(String root,
                         boolean heuristic_commit,
                         boolean checkorphans)
Constructor for testing only.


CoordinatorImp

protected CoordinatorImp(String root,
                         RecoveryCoordinator coord,
                         boolean heuristic_commit,
                         long timeout,
                         boolean checkorphans,
                         boolean single_threaded_2pc)
Constructor.

Parameters:
root - The root tid.
coord - The RecoverCoordinator, null if root.
console - The console to log to, or null if none.
heuristic_commit - Whether to do commit on heuristic.
timeout - The timeout in milliseconds for indoubts before a heuristic decision is made.
checkorphans - If true, orphan checks are made on prepare. For OTS, this is false.
single_threaded_2pc - If true then commit is done in the same thread as the one that started the tx.

CoordinatorImp

public CoordinatorImp()
No argument constructor as required by Recoverable interface.

Method Detail

getParticipants

public Vector<Participant> getParticipants()

isCommitted

public boolean isCommitted()
Tests if the transaction was committed or not.

Returns:
boolean True iff committed.

getTimeOut

protected long getTimeOut()

getState

public TxState getState()
Specified by:
getState in interface Stateful
Returns:
The object representing the state.
See Also:
Stateful

addFSMPreEnterListener

public void addFSMPreEnterListener(FSMPreEnterListener l,
                                   TxState state)
Specified by:
addFSMPreEnterListener in interface FSMPreEnterEventSource

getRecoveryCoordinator

public RecoveryCoordinator getRecoveryCoordinator()
Specified by:
getRecoveryCoordinator in interface CompositeCoordinator
See Also:
CompositeCoordinator.

getParticipant

public Participant getParticipant()
                           throws UnsupportedOperationException
Throws:
UnsupportedOperationException
See Also:
CompositeCoordinator.

getCoordinatorId

public String getCoordinatorId()
Specified by:
getCoordinatorId in interface CompositeCoordinator
See Also:
CompositeCoordinator

incLocalSiblingCount

protected void incLocalSiblingCount()
Called when a tx import is being done.


preEnter

public void preEnter(FSMEnterEvent event)
              throws IllegalStateException
Description copied from interface: FSMPreEnterListener
Called BEFORE the FSM enters the new state, so that the callee is sure that nobody has seen the new state yet.

Specified by:
preEnter in interface FSMPreEnterListener
Throws:
IllegalStateException - on failure. The callee can use this to prevent the state change from happening.
See Also:
FSMPreEnterListener.

getURI

public String getURI()
Specified by:
getURI in interface Participant
Specified by:
getURI in interface RecoveryCoordinator
See Also:
Participant

forget

public void forget()
Specified by:
forget in interface Participant
See Also:
Participant.

setCascadeList

public void setCascadeList(Map<String,Integer> allParticipants)
                    throws SysException
Specified by:
setCascadeList in interface Participant
Throws:
SysException
See Also:
Participant.

setGlobalSiblingCount

public void setGlobalSiblingCount(int count)
Specified by:
setGlobalSiblingCount in interface Participant
See Also:
Participant.

prepare

public int prepare()
            throws RollbackException,
                   IllegalStateException,
                   HeurHazardException,
                   HeurMixedException,
                   SysException
Specified by:
prepare in interface Participant
Throws:
RollbackException
IllegalStateException
HeurHazardException
HeurMixedException
SysException
See Also:
Participant.

commit

public void commit(boolean onePhase)
            throws HeurRollbackException,
                   HeurMixedException,
                   HeurHazardException,
                   IllegalStateException,
                   RollbackException,
                   SysException
Specified by:
commit in interface Participant
Throws:
HeurRollbackException
HeurMixedException
HeurHazardException
IllegalStateException
RollbackException
SysException
See Also:
Participant.

rollback

public void rollback()
              throws HeurCommitException,
                     HeurMixedException,
                     SysException,
                     HeurHazardException,
                     IllegalStateException
Specified by:
rollback in interface Participant
Throws:
HeurCommitException
HeurMixedException
SysException
HeurHazardException
IllegalStateException
See Also:
Participant.

replayCompletion

public Boolean replayCompletion(Participant participant)
                         throws IllegalStateException
Specified by:
replayCompletion in interface RecoveryCoordinator
Throws:
IllegalStateException
See Also:
RecoveryCoordinator.

getId

public Object getId()

alarm

public void alarm(AlarmTimer timer)
Specified by:
alarm in interface AlarmTimerListener

dispose

protected void dispose()

terminate

protected void terminate(boolean commit)
                  throws HeurRollbackException,
                         HeurMixedException,
                         SysException,
                         SecurityException,
                         HeurCommitException,
                         HeurHazardException,
                         RollbackException,
                         IllegalStateException
Terminate the work, on behalf of Terminator.

Parameters:
commit - True iff commit termination is asked.
Throws:
HeurRollbackException
HeurMixedException
SysException
SecurityException
HeurCommitException
HeurHazardException
RollbackException
IllegalStateException

getStateWithTwoPhaseCommitDecision

public TxState getStateWithTwoPhaseCommitDecision()

transitionPerformed

public void transitionPerformed(FSMTransitionEvent e)
Description copied from interface: FSMTransitionListener
A method to be called AFTER the specified transition is done.

Specified by:
transitionPerformed in interface FSMTransitionListener
Parameters:
e - The transition that was made.

entered

public void entered(FSMEnterEvent e)
Description copied from interface: FSMEnterListener
Called when the FSM has entered a new state.

Specified by:
entered in interface FSMEnterListener

getCoordinatorLogEntry

public CoordinatorLogEntry getCoordinatorLogEntry(TxState state)
Specified by:
getCoordinatorLogEntry in interface RecoverableCoordinator

getCoordinatorLogEntry

public CoordinatorLogEntry getCoordinatorLogEntry()

getParticipantLogEntries

public Collection<ParticipantLogEntry> getParticipantLogEntries()

isRecoverable

public boolean isRecoverable()
Specified by:
isRecoverable in interface Participant

getResourceName

public String getResourceName()
Specified by:
getResourceName in interface Participant


Copyright © 2016. All Rights Reserved.