Package com.iizix.txp.impl
Class TXPCoordinatorImpl
java.lang.Object
com.iizix.txp.impl.TXPCoordinatorImpl
- All Implemented Interfaces:
ITXPCoordinator
,ITXPMonitor
Basic and crude (for now)
ITXPCoordinator
implementation- Author:
- Freggle
Constructor Summary
ConstructorDescriptionConstructs aTXPCoordinatorImpl
instance with the default policyTXPCoordinatorImpl
(ITXPPolicy policy) Constructs aTXPCoordinatorImpl
instance with the specified policyMethod Summary
Modifier and TypeMethodDescriptionvoid
addMonitor
(ITXPMonitor monitor) Adds the specified TXP monitor.void
commit
(ITXProcess process) Called by the process to signal that the process logic/application requests a commit.Returns the coordinatorCreates a new implementation specificITXProcess
instance and sets itself as coordinator.void
onBeganProcess
(ITXProcess process) Called when a process created and associated with he controllervoid
onCommitCanceled
(ITXProcess process, TXPException reason) Called when the process aborts committing.void
onCommitInitiated
(ITXProcess process) Called when a process is called to attempt a commitvoid
onMonitorAdded
(ITXPMonitor monitor) Called when a monitor is added to the coordinator's monitor chainvoid
onMonitorRemoved
(ITXPMonitor monitor) Called when a monitor is removed from the coordinator's monitor chainvoid
onNodeAssociated
(ITXProcess process, ITXPNode node, ITXPNode.State returnedState) Called when a node is associated with a processvoid
onNodeCommitFailedPolicyAction
(ITXProcess process, ITXPNode node, ITXPPolicy.Action action) Called when the policy action is determined for a node that failed to commitvoid
onNodeDisassociated
(ITXProcess process, ITXPNode node) Called when a node is disassociated from a processvoid
onNodeReady
(ITXProcess process, ITXPNode node, ITXPNode.State returnedState) Called when a node has finished doing the work neededvoid
onNodeReadyFailedPolicyAction
(ITXProcess process, ITXPNode node, ITXPPolicy.Action action) Called when the policy action is determined for a node that failed processingvoid
onNodeRollbackFailedPolicyAction
(ITXProcess process, ITXPNode node, ITXPPolicy.Action action) Called when the policy action is determined for a node that failed to rollbackvoid
onNodeTimeoutSignaled
(ITXProcess process, ITXPNode node) Called when a node indicates it timed out waiting on the process.void
onNodeTimeoutSignaledPolicyAction
(ITXProcess process, ITXPNode node, ITXPPolicy.Action action) Called when the policy action is determined for a node that timed out waiting for completion.void
onProcessCompleted
(ITXProcess process) Called when a process has been completed (either committed or rolled back)void
onProcessCreated
(ITXProcess process) Called when the process is created.void
onProcessTimeoutSignaled
(ITXProcess process) Called when a process indicates it timed out waiting on the nodesvoid
onProcessTimeoutSignaledPolicyAction
(ITXProcess process, ITXPPolicy.Action action) Called when the policy action is determined for a process that timed out waiting for the nodes to do the work.void
onRollbackCanceled
(ITXProcess process, TXPException reason) Called when the process aborts rolling back.void
onRollbackInitiated
(ITXProcess process) Called when a process is called to attempt a rollbackvoid
ready
(ITXProcess process, ITXPNode node, ITXPNode.State nodeState) Called by the process to signal that a node is ready for completion.void
removeMonitor
(ITXPMonitor monitor) Removes the specified TXP monitor.void
rollback
(ITXProcess process) Called by the process to signal that the process logic/application requests a rollback.void
setLogger
(ITXPLogger logger) Sets the logger.
Constructor Details
TXPCoordinatorImpl
public TXPCoordinatorImpl()Constructs aTXPCoordinatorImpl
instance with the default policyTXPCoordinatorImpl
Constructs aTXPCoordinatorImpl
instance with the specified policy- Parameters:
policy
- the policy to use
Method Details
setLogger
Sets the logger.- Parameters:
logger
- The new logger instance.
newProcess
Description copied from interface:ITXPCoordinator
Creates a new implementation specificITXProcess
instance and sets itself as coordinator.- Specified by:
newProcess
in interfaceITXPCoordinator
- Returns:
- an
ITXProcess
instance
ready
Description copied from interface:ITXPCoordinator
Called by the process to signal that a node is ready for completion. Typically the coordinator handles error states that may occur using a policy.- Specified by:
ready
in interfaceITXPCoordinator
- Parameters:
process
- the processnode
- the nodenodeState
- the current state of the node
commit
Description copied from interface:ITXPCoordinator
Called by the process to signal that the process logic/application requests a commit. Typically the coordinator coordinates the commit and handles error states that may occur using a policy.- Specified by:
commit
in interfaceITXPCoordinator
- Parameters:
process
- the process- Throws:
TXPException
- a coordinator and policy dependent exception (today 1 of 3, more details later)
rollback
Description copied from interface:ITXPCoordinator
Called by the process to signal that the process logic/application requests a rollback. Typically the coordinator coordinates the commit and handles error states that may occur using a policy.- Specified by:
rollback
in interfaceITXPCoordinator
- Parameters:
process
- the process- Throws:
TXPException
- a coordinator and policy dependent exception (today 1 of 3, more details later)
addMonitor
Description copied from interface:ITXPCoordinator
Adds the specified TXP monitor. Monitors can be used for logging and monitoring processes under this coordinator's control.- Specified by:
addMonitor
in interfaceITXPCoordinator
- Parameters:
monitor
- the monitor
removeMonitor
Description copied from interface:ITXPCoordinator
Removes the specified TXP monitor.- Specified by:
removeMonitor
in interfaceITXPCoordinator
- Parameters:
monitor
- The monitor.
getCoordinator
Description copied from interface:ITXPMonitor
Returns the coordinator- Specified by:
getCoordinator
in interfaceITXPMonitor
- Returns:
- the coordinator
onMonitorAdded
Description copied from interface:ITXPMonitor
Called when a monitor is added to the coordinator's monitor chain- Specified by:
onMonitorAdded
in interfaceITXPMonitor
- Parameters:
monitor
- the monitor that got added
onMonitorRemoved
Description copied from interface:ITXPMonitor
Called when a monitor is removed from the coordinator's monitor chain- Specified by:
onMonitorRemoved
in interfaceITXPMonitor
- Parameters:
monitor
- the monitor that got removed
onBeganProcess
Description copied from interface:ITXPMonitor
Called when a process created and associated with he controller- Specified by:
onBeganProcess
in interfaceITXPMonitor
- Parameters:
process
- the process
onNodeAssociated
Description copied from interface:ITXPMonitor
Called when a node is associated with a process- Specified by:
onNodeAssociated
in interfaceITXPMonitor
- Parameters:
process
- the processnode
- the nodereturnedState
- the returned node state
onNodeDisassociated
Description copied from interface:ITXPMonitor
Called when a node is disassociated from a process- Specified by:
onNodeDisassociated
in interfaceITXPMonitor
- Parameters:
process
- the processnode
- the node
onNodeReady
Description copied from interface:ITXPMonitor
Called when a node has finished doing the work needed- Specified by:
onNodeReady
in interfaceITXPMonitor
- Parameters:
process
- the processnode
- the nodereturnedState
- the node state after attempting to do the work
onNodeTimeoutSignaled
Description copied from interface:ITXPMonitor
Called when a node indicates it timed out waiting on the process.- Specified by:
onNodeTimeoutSignaled
in interfaceITXPMonitor
- Parameters:
process
- the processnode
- the node
onProcessTimeoutSignaled
Description copied from interface:ITXPMonitor
Called when a process indicates it timed out waiting on the nodes- Specified by:
onProcessTimeoutSignaled
in interfaceITXPMonitor
- Parameters:
process
- the process
onCommitInitiated
Description copied from interface:ITXPMonitor
Called when a process is called to attempt a commit- Specified by:
onCommitInitiated
in interfaceITXPMonitor
- Parameters:
process
- the process
onCommitCanceled
Description copied from interface:ITXPMonitor
Called when the process aborts committing. This can happen if a rollback is requested or one or more nodes have not yet finished processing.- Specified by:
onCommitCanceled
in interfaceITXPMonitor
- Parameters:
process
- the processreason
- the exception thrown by the commit
onRollbackInitiated
Description copied from interface:ITXPMonitor
Called when a process is called to attempt a rollback- Specified by:
onRollbackInitiated
in interfaceITXPMonitor
- Parameters:
process
- the process
onRollbackCanceled
Description copied from interface:ITXPMonitor
Called when the process aborts rolling back. This can happen if one or more nodes have not yet finished processing.- Specified by:
onRollbackCanceled
in interfaceITXPMonitor
- Parameters:
process
- the processreason
- the exception thrown by the rollback
onNodeReadyFailedPolicyAction
public void onNodeReadyFailedPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action) Description copied from interface:ITXPMonitor
Called when the policy action is determined for a node that failed processing- Specified by:
onNodeReadyFailedPolicyAction
in interfaceITXPMonitor
- Parameters:
process
- the processnode
- the nodeaction
- the policy action
onNodeCommitFailedPolicyAction
public void onNodeCommitFailedPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action) Description copied from interface:ITXPMonitor
Called when the policy action is determined for a node that failed to commit- Specified by:
onNodeCommitFailedPolicyAction
in interfaceITXPMonitor
- Parameters:
process
- the processnode
- the nodeaction
- the action
onNodeRollbackFailedPolicyAction
public void onNodeRollbackFailedPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action) Description copied from interface:ITXPMonitor
Called when the policy action is determined for a node that failed to rollback- Specified by:
onNodeRollbackFailedPolicyAction
in interfaceITXPMonitor
- Parameters:
process
- the processnode
- the nodeaction
- the action
onNodeTimeoutSignaledPolicyAction
public void onNodeTimeoutSignaledPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action) Description copied from interface:ITXPMonitor
Called when the policy action is determined for a node that timed out waiting for completion.- Specified by:
onNodeTimeoutSignaledPolicyAction
in interfaceITXPMonitor
- Parameters:
process
- the processnode
- the nodeaction
- the action
onProcessTimeoutSignaledPolicyAction
Description copied from interface:ITXPMonitor
Called when the policy action is determined for a process that timed out waiting for the nodes to do the work.- Specified by:
onProcessTimeoutSignaledPolicyAction
in interfaceITXPMonitor
- Parameters:
process
- the processaction
- the action
onProcessCreated
Description copied from interface:ITXPMonitor
Called when the process is created.- Specified by:
onProcessCreated
in interfaceITXPMonitor
- Parameters:
process
- The process.
onProcessCompleted
Description copied from interface:ITXPMonitor
Called when a process has been completed (either committed or rolled back)- Specified by:
onProcessCompleted
in interfaceITXPMonitor
- Parameters:
process
- The process.