Package com.iizix.txp
Interface ITXPNode
- All Known Subinterfaces:
- IJavaActionActor
- All Known Implementing Classes:
- AbstractActionActorTXPNode,- AbstractJavaActionActor,- AbstractTXPNode,- DatabaseActionTXPNode,- TestJavaActionActor
public interface ITXPNode
The ITXPNode interface abstracts a unit of work in a transactional process. The interface is used by the 
ITXProcess implementation the node is associated with and its ITXPCoordinator implementation. The process is itself guided by the ITXPCoordinator. The coordinator can be seen as enforcing a policy.- Author:
- Freggle
- Nested Class SummaryNested Classes
- Method SummaryModifier and TypeMethodDescription- begin- (ITXProcess process, ITXPid pid) Notifies the node it got associated with a transactional process.- commit- (ITXProcess process) Instructs the node to commit the work.- void- forget- (ITXProcess process) Notifies the node it got disassociated from the process ie it can abort, rollback (if needed) and forget about the process.- getPid()Gets the pid of this node.- getState()Returns the 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 called- booleanCheck if timeout has been called- booleanAsks if the node is idempotent.- void- processTimeout- (ITXProcess process) Called by a process to indicate it timed out waiting for all nodes to complete the work.- 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.- rollback- (ITXProcess process) Instructs the node to roll back the work.- 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.
- Method Details- getPidITXPid getPid()Gets the pid of this node.- Returns:
- the pid
 
- getStateITXPNode.State getState()Returns the state of the node.- Returns:
- the state
 
- isIdempotentboolean isIdempotent()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.- Returns:
- true if this node is idempotent, false if not
 
- getTimeoutlong getTimeout()Gets the time in milliseconds this node will wait for a commit() or rollback() call after it is ready.- Returns:
- the timeout in milliseconds
 
- beginNotifies the node it got associated with a transactional process. The node should set up its local transaction context and set and respond with either- ITXPNode.State.WORKINGor- ITXPNode.State.FAILEDdepending on its state.- Parameters:
- process- the process
- pid- the pid for this node of the process
- Returns:
- the state of the node
 
- forgetNotifies the node it got disassociated from the process ie it can abort, rollback (if needed) and forget about the process.- Parameters:
- process- the process
 
- timeoutCalled 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.- Parameters:
- process- the process that timed out
 
- processTimeoutCalled 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.- Parameters:
- process- the process that timed out
 
- hasTimedOutboolean hasTimedOut()Check if timeout has been called- Returns:
- true if timeout has been called
 
- hasProcessTimedOutboolean hasProcessTimedOut()Check if processTimeout has been called- Returns:
- try if processTimeout has been called
 
- commitInstructs the node to commit the work. The node should set and respond with either- ITXPNode.State.COMPLETEDor- ITXPNode.State.FAILEDdepending on its state. If a commit failed the node is expected to have rolled back the work.- Parameters:
- process- the process
- Returns:
- the state of the node
 
- rollbackInstructs the node to roll back the work. The node should set and respond with either- ITXPNode.State.COMPLETEDor- ITXPNode.State.FAILEDdepending on its state. NOTE if the node failed its work it is already rolled back and will return- ITXPNode.State.COMPLETEDbut remain in state.- ITXPNode.State.FAILED- Parameters:
- process- the process
- Returns:
- the state of the node
 
- retryInstructs 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.- Parameters:
- process- the process
- Returns:
- the state of the node
 
- undoInstructs 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.- Parameters:
- process- the process
- Returns:
- the state of the node
 
- recoverThis 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.- Parameters:
- process- the process
- Returns:
- the state of the node