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 booleanhasProcessTimedOutprotected booleanhasTimedOutprotected booleanhasTimedOutWaitingprotected ITXPidpidThe Pidprotected ITXProcessprocessThe process this node is associated withprotected ITXPNode.StatestateThe current state of the nodeprotected longtimeoutThe timeout value for this node (default indefinite)protected ITimeoutTasktimeoutTaskprotected ITXPNodeLoggertxplog
Constructor Summary
Constructors Constructor Description AbstractTXPNode()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcancelTimeout()protected voidcreateLogger()ITXPidgetPid()Gets the pid of this node.protected ITXProcessgetProcess()Gets the process this node is associated with.ITXPNode.StategetState()Gets the current state of the node.longgetTimeout()Gets the time in milliseconds this node will wait for a commit() or rollback() call after it is ready.booleanhasProcessTimedOut()Check if processTimeout has been calledbooleanhasTimedOut()Check if timeout has been calledprotected booleanhasTimedOutWaiting()booleanisIdempotent()Asks if the node is idempotent.protected ITXPNodeLoggerlog()voidonTimeout()Called when timeout is reached.voidprocessTimeout(ITXProcess process)Called by a process to indicate it timed out waiting for all nodes to complete the work.protected voidready()ITXPNode.Staterecover(ITXProcess process)This method instructs an node to recover a process after some sort of system failure.ITXPNode.Stateretry(ITXProcess process)Instructs the node to retry the work.voidsetTimeout(long t)voidtimeout(ITXProcess process)Called by a process to indicate it timed out waiting for this node.ITXPNode.Stateundo(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 interfaceITXPNode- 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 interfaceITXPNode- 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 eitherITXPNode.State.OK,ITXPNode.State.FAILEDorITXPNode.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 eitherITXPNode.State.OK,ITXPNode.State.FAILEDorITXPNode.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 eitherITXPNode.State.OK,ITXPNode.State.FAILEDorITXPNode.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 interfaceITXPNode- Parameters:
process- the process that timed out
onTimeout
public void onTimeout()
Description copied from interface:ITimeoutListenerCalled when timeout is reached.- Specified by:
onTimeoutin interfaceITimeoutListener
hasTimedOut
public boolean hasTimedOut()
Description copied from interface:ITXPNodeCheck if timeout has been called- Specified by:
hasTimedOutin interfaceITXPNode- Returns:
- true if timeout has been called
hasProcessTimedOut
public boolean hasProcessTimedOut()
Description copied from interface:ITXPNodeCheck if processTimeout has been called- Specified by:
hasProcessTimedOutin interfaceITXPNode- 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()