Package com.iizix.txp
Interface ITXPNode
- All Known Subinterfaces:
- IJavaActionActor
 - All Known Implementing Classes:
- AbstractActionActorTXPNode,- AbstractJavaActionActor,- AbstractTXPNode,- DatabaseActionTXPNode,- TestJavaActionActor
 - public interface ITXPNodeThe ITXPNode interface abstracts a unit of work in a transactional process. The interface is used by the- ITXProcessimplementation the node is associated with and its- ITXPCoordinatorimplementation. The process is itself guided by the- ITXPCoordinator. The coordinator can be seen as enforcing a policy.- Author:
- Freggle
 
- Nested Class Summary- Nested Classes - Modifier and Type - Interface - Description - static class- ITXPNode.StateState enum for a- ITXPNode.
 - Method Summary- All Methods Instance Methods Abstract Methods - Modifier and Type - Method - Description - ITXPNode.State- begin(ITXProcess process, ITXPid pid)Notifies the node it got associated with a transactional process.- ITXPNode.State- 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.- ITXPid- getPid()Gets the pid of this node.- ITXPNode.State- getState()Returns the 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- boolean- isIdempotent()Asks 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.- 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.- ITXPNode.State- 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.- ITXPNode.State- undo(ITXProcess process)Instructs the node to undo the committed work.
 
- Method Detail- getPid- ITXPid getPid() Gets the pid of this node.- Returns:
- the pid
 
 - getState- ITXPNode.State getState() Returns the state of the node.- Returns:
- the state
 
 - isIdempotent- boolean 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
 
 - getTimeout- long 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
 
 - begin- ITXPNode.State begin(ITXProcess process, ITXPid pid) Notifies 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
 
 - forget- 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.- Parameters:
- process- the process
 
 - timeout- void timeout(ITXProcess process) 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.- Parameters:
- process- the process that timed out
 
 - processTimeout- void processTimeout(ITXProcess process) 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.- Parameters:
- process- the process that timed out
 
 - hasTimedOut- boolean hasTimedOut() Check if timeout has been called- Returns:
- true if timeout has been called
 
 - hasProcessTimedOut- boolean hasProcessTimedOut() Check if processTimeout has been called- Returns:
- try if processTimeout has been called
 
 - commit- ITXPNode.State commit(ITXProcess process) Instructs 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
 
 - rollback- ITXPNode.State rollback(ITXProcess process) Instructs 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
 
 - retry- ITXPNode.State retry(ITXProcess process) Instructs 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
 
 - undo- ITXPNode.State undo(ITXProcess process) Instructs 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
 
 - recover- ITXPNode.State recover(ITXProcess process) 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 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