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.State
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
protected boolean
protected ITXPid
The Pidprotected ITXProcess
The process this node is associated withprotected ITXPNode.State
The current state of the nodeprotected long
The timeout value for this node (default indefinite)protected ITimeoutTask
protected ITXPNodeLogger
Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
getPid()
Gets the pid of this node.protected ITXProcess
Gets the process this node is associated with.getState()
Gets the current state of the node.long
Gets the time in milliseconds this node will wait for a commit() or rollback() call after it is ready.boolean
Check if processTimeout has been calledboolean
Check if timeout has been calledprotected boolean
boolean
Asks if the node is idempotent.protected ITXPNodeLogger
log()
void
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()
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.void
setTimeout
(long t) void
timeout
(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:ITXPNode
Gets the pid of this node.isIdempotent
public boolean isIdempotent()Description copied from interface:ITXPNode
Asks 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:
isIdempotent
in interfaceITXPNode
- Returns:
- true if this node is idempotent, false if not
getTimeout
public long getTimeout()Description copied from interface:ITXPNode
Gets the time in milliseconds this node will wait for a commit() or rollback() call after it is ready.- Specified by:
getTimeout
in interfaceITXPNode
- Returns:
- the timeout in milliseconds
setTimeout
public void setTimeout(long t) retry
Description copied from interface:ITXPNode
Instructs the node to retry the work. The node should set and respond with eitherITXPNode.State.OK
,ITXPNode.State.FAILED
orITXPNode.State.UNABLE
depending on its state.undo
Description copied from interface:ITXPNode
Instructs the node to undo the committed work. The node should set and respond with eitherITXPNode.State.OK
,ITXPNode.State.FAILED
orITXPNode.State.UNABLE
depending 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:ITXPNode
This 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.FAILED
orITXPNode.State.UNABLE
depending 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:ITXPNode
Called 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:ITXPNode
Called 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:
processTimeout
in interfaceITXPNode
- Parameters:
process
- the process that timed out
onTimeout
public void onTimeout()Description copied from interface:ITimeoutListener
Called when timeout is reached.- Specified by:
onTimeout
in interfaceITimeoutListener
hasTimedOut
public boolean hasTimedOut()Description copied from interface:ITXPNode
Check if timeout has been called- Specified by:
hasTimedOut
in interfaceITXPNode
- Returns:
- true if timeout has been called
hasProcessTimedOut
public boolean hasProcessTimedOut()Description copied from interface:ITXPNode
Check if processTimeout has been called- Specified by:
hasProcessTimedOut
in 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