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 Summary
Method Summary
Modifier and TypeMethodDescriptionbegin
(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.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 calledboolean
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.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
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
Notifies the node it got associated with a transactional process. The node should set up its local transaction context and set and respond with eitherITXPNode.State.WORKING
orITXPNode.State.FAILED
depending on its state.- Parameters:
process
- the processpid
- the pid for this node of the process- Returns:
- the state of the node
forget
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
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
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
Instructs the node to commit the work. The node should set and respond with eitherITXPNode.State.COMPLETED
orITXPNode.State.FAILED
depending 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
Instructs the node to roll back the work. The node should set and respond with eitherITXPNode.State.COMPLETED
orITXPNode.State.FAILED
depending on its state. NOTE if the node failed its work it is already rolled back and will returnITXPNode.State.COMPLETED
but remain in state.ITXPNode.State.FAILED
- Parameters:
process
- the process- Returns:
- the state of the node
retry
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.- Parameters:
process
- the process- Returns:
- the state of the node
undo
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.- Parameters:
process
- the process- Returns:
- the state of the node
recover
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.- Parameters:
process
- the process- Returns:
- the state of the node