Package com.iizix.txp.impl
Class AbstractTXPNode
java.lang.Object
com.iizix.txp.impl.AbstractTXPNode
- All Implemented Interfaces:
ITimeoutListener,ITXPNode
- Direct Known Subclasses:
AbstractActionActorTXPNode
- Author:
- Freggle
Nested Class Summary
Nested classes/interfaces inherited from interface com.iizix.txp.ITXPNode
ITXPNode.StateField Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected booleanprotected ITXPidThe Pidprotected ITXProcessThe process this node is associated withprotected ITXPNode.StateThe current state of the nodeprotected longThe timeout value for this node (default indefinite)protected ITimeoutTaskprotected ITXPNodeLoggerConstructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidgetPid()Gets the pid of this node.protected ITXProcessGets the process this node is associated with.getState()Gets the current state of the node.longGets the time in milliseconds this node will wait for a commit() or rollback() call after it is ready.booleanCheck if processTimeout has been calledbooleanCheck if timeout has been calledprotected booleanbooleanAsks if the node is idempotent.protected ITXPNodeLoggerlog()voidCalled 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()recover(ITXProcess process) This method instructs an node to recover a process after some sort of system failure.retry(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.undo(ITXProcess process) Instructs the node to undo the committed work.
Field Details
pid
The Pidprocess
The process this node is associated withtxplog
state
The current state of the nodetimeout
protected long timeoutThe timeout value for this node (default indefinite)timeoutTask
hasTimedOutWaiting
protected volatile boolean hasTimedOutWaitinghasTimedOut
protected volatile boolean hasTimedOuthasProcessTimedOut
protected volatile boolean hasProcessTimedOut
Constructor Details
AbstractTXPNode
public AbstractTXPNode()
Method Details
getPid
Description copied from interface:ITXPNodeGets the pid of this node.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
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
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
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
Gets the current state of the node.timeout
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
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
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