com.atomikos.icatch.imp
Class HeurAbortedStateHandler

java.lang.Object
  extended by com.atomikos.icatch.imp.HeurAbortedStateHandler
All Implemented Interfaces:
DataSerializable, Serializable, Cloneable

public class HeurAbortedStateHandler
extends Object

A state handler for the heuristic abort coordinator state.

See Also:
Serialized Form

Constructor Summary
HeurAbortedStateHandler()
           
 
Method Summary
protected  void activate()
          Start the threads.
protected  void addAllForReplay(Collection<Participant> participants)
          Utility method for subclasses.
protected  void addToHeuristicMap(Hashtable participants)
          Adds a map of participants -> heuristic states to the map of heuristic states -> participants.
protected  void addToHeuristicMap(Participant p, Object state)
          Adds a participant with a given heuristic state to the map.
 Object clone()
          Performs a deep clone of the state handler, needed for logging the state information in this handler.
protected  HeuristicMessage[] commit(boolean onePhase)
          The corresponding 2PC method is delegated hereto.
protected  HeuristicMessage[] commitFromWithinCallback(boolean heuristic, boolean onePhase)
          Auxiliary method for committing.
 HeuristicMessage[] commitHeuristically()
           
protected  void dispose()
          Notification of shutdown; this method triggers the stopping of all active threads for propagation.
protected  void forget()
           
protected  Dictionary getCascadeList()
          Get the cascade list.
protected  Boolean getCommitted()
          Test if the result was commit.
protected  CoordinatorImp getCoordinator()
          Get the coordinator whose state we handle.
protected  HeuristicMessage[] getHeuristicMessages()
          Get the heuristic info for the message round.
protected  HeuristicMessage[] getHeuristicMessages(Object heuristicState)
          Gets the heuristic messages for all participants that are in the given heuristic state
protected  com.atomikos.icatch.imp.Propagator getPropagator()
          Get the propagator for sending messages in the subclasses.
protected  Hashtable getReadOnlyTable()
          Get the readonly table.
protected  Stack getReplayStack()
          Get the replay stack for replay completion requests.
protected  long getRollbackTicks()
           
protected  TxState getState()
          Get the (non-pseudo) coordinator state to which this handler belongs.
protected  boolean isCommitted()
          Tests if commit has happened.
protected  void onTimeout()
          Callback method on timeout event of the coordinator.
protected  int prepare()
          The corresponding 2PC method is delegated hereto.
 void readData(DataInput in)
           
protected  void recover(CoordinatorImp coordinator)
          Recover the state handler after restart.
protected  Boolean replayCompletion(Participant participant)
          Handle a replay request for a participant.
protected  HeuristicMessage[] rollback()
          The corresponding 2PC method is delegated hereto.
protected  HeuristicMessage[] rollbackFromWithinCallback(boolean indoubt, boolean heuristic)
          Auxiliary method for rollback.
 HeuristicMessage[] rollbackHeuristically()
           
 HeuristicMessage[] rollbackWithAfterCompletionNotification(com.atomikos.icatch.imp.RollbackCallback cb)
           
protected  void setCascadeList(Dictionary<Participant,Integer> allParticipants)
          The corresponding 2PC method is delegated hereto.
protected  void setGlobalSiblingCount(int count)
          The corresponding 2PC method is delegated hereto.
protected  void setReadOnlyTable(Hashtable table)
          Sets the table of readonly participants.
 void writeData(DataOutput out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeurAbortedStateHandler

public HeurAbortedStateHandler()
Method Detail

getState

protected TxState getState()
Get the (non-pseudo) coordinator state to which this handler belongs.

Returns:
Object The object that represents the corresponding coordinator state.

onTimeout

protected void onTimeout()
Callback method on timeout event of the coordinator. The interpretation of timeout will typically be different for each state handler; some may rollback while others need to inquire about completion. This method should also check any replay requests.


setGlobalSiblingCount

protected void setGlobalSiblingCount(int count)
The corresponding 2PC method is delegated hereto.


prepare

protected int prepare()
               throws RollbackException,
                      IllegalStateException,
                      HeurHazardException,
                      HeurMixedException,
                      SysException
The corresponding 2PC method is delegated hereto.

Throws:
RollbackException
IllegalStateException
HeurHazardException
HeurMixedException
SysException

commit

protected HeuristicMessage[] commit(boolean onePhase)
                             throws HeurRollbackException,
                                    HeurMixedException,
                                    HeurHazardException,
                                    IllegalStateException,
                                    RollbackException,
                                    SysException
The corresponding 2PC method is delegated hereto. Subclasses should override this, and may use the auxiliary commit method provided by this class (in addition to their state-specific preconditions).

Throws:
HeurRollbackException
HeurMixedException
HeurHazardException
IllegalStateException
RollbackException
SysException

rollback

protected HeuristicMessage[] rollback()
                               throws HeurCommitException,
                                      HeurMixedException,
                                      SysException,
                                      HeurHazardException,
                                      IllegalStateException
The corresponding 2PC method is delegated hereto. Subclasses should override this, and may use the auxiliary rollback method provided by this class (in addition to their state-specific preconditions).

Throws:
HeurCommitException
HeurMixedException
SysException
HeurHazardException
IllegalStateException

clone

public Object clone()
Performs a deep clone of the state handler, needed for logging the state information in this handler.

Overrides:
clone in class Object
Returns:
Object The deep clone.

addToHeuristicMap

protected void addToHeuristicMap(Participant p,
                                 Object state)
Adds a participant with a given heuristic state to the map.

Parameters:
p - The participant.
state - The (heuristic) state. Should be one of the four heuristic states, or the terminated state.

addToHeuristicMap

protected void addToHeuristicMap(Hashtable participants)
Adds a map of participants -> heuristic states to the map of heuristic states -> participants. This method is called after heuristics on commit/rollback, and allows to retrieve the exact state of each single participant in case of heuristic terminations.

Parameters:
participants - The participant to heuristic state map.

getHeuristicMessages

protected HeuristicMessage[] getHeuristicMessages(Object heuristicState)
Gets the heuristic messages for all participants that are in the given heuristic state

Parameters:
heuristicState - The heuristic state, or the terminated state.
Returns:
HeuristicMessage[] The heuristic messages of all participants in the given state, or an empty array if none.

getHeuristicMessages

protected HeuristicMessage[] getHeuristicMessages()
Get the heuristic info for the message round.

Returns:
HeuristicMessages[] The heuristic messages, or an empty array if none.

getCoordinator

protected CoordinatorImp getCoordinator()
Get the coordinator whose state we handle.

Returns:
CoordinatorImp The coordinator.

getRollbackTicks

protected long getRollbackTicks()

getReplayStack

protected Stack getReplayStack()
Get the replay stack for replay completion requests.

Returns:
Stack The stack with replay requests, or an empty stack if none are present.

getReadOnlyTable

protected Hashtable getReadOnlyTable()
Get the readonly table.

Returns:
The table.

getCascadeList

protected Dictionary getCascadeList()
Get the cascade list.

Returns:
Dictionary The cascade list.

getPropagator

protected com.atomikos.icatch.imp.Propagator getPropagator()
Get the propagator for sending messages in the subclasses.

Returns:
Propagator The propagator.

getCommitted

protected Boolean getCommitted()
Test if the result was commit.

Returns:
Boolean Null if not known yet, True if commit, False if rollback.

isCommitted

protected boolean isCommitted()
Tests if commit has happened.

Returns:
boolean True iff commit happened.

setReadOnlyTable

protected void setReadOnlyTable(Hashtable table)
Sets the table of readonly participants.

Parameters:
table - The table.

activate

protected void activate()
Start the threads. This method should be called when the state handler should start being active, as the first method for recovered instances or when the constructor without a propagator argument is called.


recover

protected void recover(CoordinatorImp coordinator)
Recover the state handler after restart. For safety, this method should be called AFTER activate has been called, or recovery may not work fine!

Parameters:
coordinator - The (transient) coordinator to use.

dispose

protected void dispose()
Notification of shutdown; this method triggers the stopping of all active threads for propagation.


replayCompletion

protected Boolean replayCompletion(Participant participant)
                            throws IllegalStateException
Handle a replay request for a participant. This method makes the participant eligible for replay on the next timer event, but does nothing else. Subclasses should take care of checking preconditions!

Returns:
Boolean Indication of the termination decision, null if not known yet.
Throws:
IllegalStateException

addAllForReplay

protected void addAllForReplay(Collection<Participant> participants)
Utility method for subclasses.

Parameters:
participants -

setCascadeList

protected void setCascadeList(Dictionary<Participant,Integer> allParticipants)
The corresponding 2PC method is delegated hereto.


commitFromWithinCallback

protected HeuristicMessage[] commitFromWithinCallback(boolean heuristic,
                                                      boolean onePhase)
                                               throws HeurRollbackException,
                                                      HeurMixedException,
                                                      HeurHazardException,
                                                      IllegalStateException,
                                                      RollbackException,
                                                      SysException
Auxiliary method for committing. This method can be reused in subclasses in order to process commit.

Parameters:
heuristic - True iff a heuristic commit should be done.
onePhase - True iff one-phase commit.
Throws:
HeurRollbackException
HeurMixedException
HeurHazardException
IllegalStateException
RollbackException
SysException

rollbackFromWithinCallback

protected HeuristicMessage[] rollbackFromWithinCallback(boolean indoubt,
                                                        boolean heuristic)
                                                 throws HeurCommitException,
                                                        HeurMixedException,
                                                        SysException,
                                                        HeurHazardException,
                                                        IllegalStateException
Auxiliary method for rollback. This method can be reused in subclasses in order to process rollback.

Parameters:
indoubt - True iff some participants may already have voted YES.
heuristic - True iff a heuristic commit should be done.
Throws:
HeurCommitException
HeurMixedException
SysException
HeurHazardException
IllegalStateException

forget

protected void forget()

rollbackWithAfterCompletionNotification

public HeuristicMessage[] rollbackWithAfterCompletionNotification(com.atomikos.icatch.imp.RollbackCallback cb)
                                                           throws HeurCommitException,
                                                                  HeurMixedException,
                                                                  SysException,
                                                                  HeurHazardException,
                                                                  IllegalStateException
Throws:
HeurCommitException
HeurMixedException
SysException
HeurHazardException
IllegalStateException

rollbackHeuristically

public HeuristicMessage[] rollbackHeuristically()
                                         throws HeurCommitException,
                                                HeurMixedException,
                                                SysException,
                                                HeurHazardException,
                                                IllegalStateException
Throws:
HeurCommitException
HeurMixedException
SysException
HeurHazardException
IllegalStateException

commitHeuristically

public HeuristicMessage[] commitHeuristically()
                                       throws HeurMixedException,
                                              SysException,
                                              HeurRollbackException,
                                              HeurHazardException,
                                              IllegalStateException,
                                              RollbackException
Throws:
HeurMixedException
SysException
HeurRollbackException
HeurHazardException
IllegalStateException
RollbackException

writeData

public void writeData(DataOutput out)
               throws IOException
Specified by:
writeData in interface DataSerializable
Throws:
IOException

readData

public void readData(DataInput in)
              throws IOException
Specified by:
readData in interface DataSerializable
Throws:
IOException


Copyright © 2014. All Rights Reserved.