Package com.iizix.txp.impl
Class AbstractTXPNode
- java.lang.Object
- com.iizix.txp.impl.AbstractTXPNode
 
- All Implemented Interfaces:
- ITimeoutListener,- ITXPNode
 - Direct Known Subclasses:
- AbstractActionActorTXPNode
 - public abstract class AbstractTXPNode extends java.lang.Object implements ITXPNode, ITimeoutListener - Author:
- Freggle
 
- Nested Class Summary- Nested classes/interfaces inherited from interface com.iizix.txp.ITXPNode- ITXPNode.State
 
 - Field Summary- Fields - Modifier and Type - Field - Description - protected boolean- hasProcessTimedOut- protected boolean- hasTimedOut- protected boolean- hasTimedOutWaiting- protected ITXPid- pidThe Pid- protected ITXProcess- processThe process this node is associated with- protected ITXPNode.State- stateThe current state of the node- protected long- timeoutThe timeout value for this node (default indefinite)- protected ITimeoutTask- timeoutTask- protected ITXPNodeLogger- txplog
 - Constructor Summary- Constructors - Constructor - Description - AbstractTXPNode()
 - Method Summary- All Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - protected void- cancelTimeout()- protected void- createLogger()- ITXPid- getPid()Gets the pid of this node.- protected ITXProcess- getProcess()Gets the process this node is associated with.- ITXPNode.State- getState()Gets the current state of the node.- long- getTimeout()Gets the time in milliseconds this node will wait for a commit() or rollback() call after it is ready.- boolean- hasProcessTimedOut()Check if processTimeout has been called- boolean- hasTimedOut()Check if timeout has been called- protected boolean- hasTimedOutWaiting()- boolean- isIdempotent()Asks if the node is idempotent.- protected ITXPNodeLogger- log()- void- onTimeout()Called when timeout is reached.- void- processTimeout(ITXProcess process)Called by a process to indicate it timed out waiting for all nodes to complete the work.- protected void- ready()- ITXPNode.State- recover(ITXProcess process)This method instructs an node to recover a process after some sort of system failure.- ITXPNode.State- retry(ITXProcess process)Instructs the node to retry the work.- void- setTimeout(long t)- void- timeout(ITXProcess process)Called by a process to indicate it timed out waiting for this node.- ITXPNode.State- undo(ITXProcess process)Instructs the node to undo the committed work.
 
- Field Detail- pid- protected ITXPid pid The Pid
 - process- protected ITXProcess process The process this node is associated with
 - txplog- protected ITXPNodeLogger txplog 
 - state- protected ITXPNode.State state The current state of the node
 - timeout- protected long timeout The timeout value for this node (default indefinite)
 - timeoutTask- protected ITimeoutTask timeoutTask 
 - hasTimedOutWaiting- protected volatile boolean hasTimedOutWaiting 
 - hasTimedOut- protected volatile boolean hasTimedOut 
 - hasProcessTimedOut- protected volatile boolean hasProcessTimedOut 
 
 - Method Detail- isIdempotent- public boolean isIdempotent() Description copied from interface:- ITXPNodeAsks if the node is idempotent. Idempotent means f(f(x)) = f(x). For instance: if the node turns on a light, turning it on again has the same result: the light is on.- Specified by:
- isIdempotentin interface- ITXPNode
- Returns:
- true if this node is idempotent, false if not
 
 - getTimeout- public long getTimeout() Description copied from interface:- ITXPNodeGets the time in milliseconds this node will wait for a commit() or rollback() call after it is ready.- Specified by:
- getTimeoutin interface- ITXPNode
- Returns:
- the timeout in milliseconds
 
 - setTimeout- public void setTimeout(long t) 
 - retry- public ITXPNode.State retry(ITXProcess process) Description copied from interface:- ITXPNodeInstructs the node to retry the work. The node should set and respond with either- ITXPNode.State.OK,- ITXPNode.State.FAILEDor- ITXPNode.State.UNABLEdepending on its state.
 - undo- public ITXPNode.State undo(ITXProcess process) Description copied from interface:- ITXPNodeInstructs the node to undo the committed work. The node should set and respond with either- ITXPNode.State.OK,- ITXPNode.State.FAILEDor- ITXPNode.State.UNABLEdepending on its state. This is of course the 'crux'. It is the implementation that may or may not be able to undo something. For instance. if the node is a JDBC transaction it may know how to perform a compensating transaction; or not.
 - recover- public ITXPNode.State recover(ITXProcess process) Description copied from interface:- ITXPNodeThis method instructs an node to recover a process after some sort of system failure. In effect this means restoring the state of the ITXPNode to the last known state with regards to the specified process. The node should set and respond with either- ITXPNode.State.OK,- ITXPNode.State.FAILEDor- ITXPNode.State.UNABLEdepending on its state. To be able to do this the node needs to log its state durably and use the Processes Pid as a key.
 - getState- public ITXPNode.State getState() Gets the current state of the node.
 - timeout- public void timeout(ITXProcess process) Description copied from interface:- ITXPNodeCalled by a process to indicate it timed out waiting for this node. The node should abandon the work and wait for rollback or return READ_ONLY if it can.
 - processTimeout- public void processTimeout(ITXProcess process) Description copied from interface:- ITXPNodeCalled by a process to indicate it timed out waiting for all nodes to complete the work. The node should abandon the work if it can and wait for rollback or return READ_ONLY if it can.- Specified by:
- processTimeoutin interface- ITXPNode
- Parameters:
- process- the process that timed out
 
 - onTimeout- public void onTimeout() Description copied from interface:- ITimeoutListenerCalled when timeout is reached.- Specified by:
- onTimeoutin interface- ITimeoutListener
 
 - hasTimedOut- public boolean hasTimedOut() Description copied from interface:- ITXPNodeCheck if timeout has been called- Specified by:
- hasTimedOutin interface- ITXPNode
- Returns:
- true if timeout has been called
 
 - hasProcessTimedOut- public boolean hasProcessTimedOut() Description copied from interface:- ITXPNodeCheck if processTimeout has been called- Specified by:
- hasProcessTimedOutin interface- ITXPNode
- Returns:
- try if processTimeout has been called
 
 - getProcess- protected ITXProcess getProcess() Gets the process this node is associated with.- Returns:
- Returns the TXProcess instance.
 
 - ready- protected void ready() 
 - hasTimedOutWaiting- protected boolean hasTimedOutWaiting() 
 - cancelTimeout- protected void cancelTimeout() 
 - createLogger- protected void createLogger() 
 - log- protected ITXPNodeLogger log()