Package com.iizix.txp.impl
Class TXPCoordinatorImpl
- java.lang.Object
- com.iizix.txp.impl.TXPCoordinatorImpl
- All Implemented Interfaces:
ITXPCoordinator,ITXPMonitor
public class TXPCoordinatorImpl extends java.lang.Object implements ITXPCoordinator
Basic and crude (for now)ITXPCoordinatorimplementation- Author:
- Freggle
Constructor Summary
Constructors Constructor Description TXPCoordinatorImpl()Constructs aTXPCoordinatorImplinstance with the default policyTXPCoordinatorImpl(ITXPPolicy policy)Constructs aTXPCoordinatorImplinstance with the specified policy
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMonitor(ITXPMonitor monitor)Adds the specified TXP monitor.voidcommit(ITXProcess process)Called by the process to signal that the process logic/application requests a commit.ITXPCoordinatorgetCoordinator()Returns the coordinatorITXProcessnewProcess()Creates a new implementation specificITXProcessinstance and sets itself as coordinator.voidonBeganProcess(ITXProcess process)Called when a process created and associated with he controllervoidonCommitCanceled(ITXProcess process, TXPException reason)Called when the process aborts committing.voidonCommitInitiated(ITXProcess process)Called when a process is called to attempt a commitvoidonMonitorAdded(ITXPMonitor monitor)Called when a monitor is added to the coordinator's monitor chainvoidonMonitorRemoved(ITXPMonitor monitor)Called when a monitor is removed from the coordinator's monitor chainvoidonNodeAssociated(ITXProcess process, ITXPNode node, ITXPNode.State returnedState)Called when a node is associated with a processvoidonNodeCommitFailedPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action)Called when the policy action is determined for a node that failed to commitvoidonNodeDisassociated(ITXProcess process, ITXPNode node)Called when a node is disassociated from a processvoidonNodeReady(ITXProcess process, ITXPNode node, ITXPNode.State returnedState)Called when a node has finished doing the work neededvoidonNodeReadyFailedPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action)Called when the policy action is determined for a node that failed processingvoidonNodeRollbackFailedPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action)Called when the policy action is determined for a node that failed to rollbackvoidonNodeTimeoutSignaled(ITXProcess process, ITXPNode node)Called when a node indicates it timed out waiting on the process.voidonNodeTimeoutSignaledPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action)Called when the policy action is determined for a node that timed out waiting for completion.voidonProcessCompleted(ITXProcess process)Called when a process has been completed (either committed or rolled back)voidonProcessCreated(ITXProcess process)Called when the process is created.voidonProcessTimeoutSignaled(ITXProcess process)Called when a process indicates it timed out waiting on the nodesvoidonProcessTimeoutSignaledPolicyAction(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.voidonRollbackCanceled(ITXProcess process, TXPException reason)Called when the process aborts rolling back.voidonRollbackInitiated(ITXProcess process)Called when a process is called to attempt a rollbackvoidready(ITXProcess process, ITXPNode node, ITXPNode.State nodeState)Called by the process to signal that a node is ready for completion.voidremoveMonitor(ITXPMonitor monitor)Removes the specified TXP monitor.voidrollback(ITXProcess process)Called by the process to signal that the process logic/application requests a rollback.voidsetLogger(ITXPLogger logger)Sets the logger.
Constructor Detail
TXPCoordinatorImpl
public TXPCoordinatorImpl()
Constructs aTXPCoordinatorImplinstance with the default policy
TXPCoordinatorImpl
public TXPCoordinatorImpl(ITXPPolicy policy)
Constructs aTXPCoordinatorImplinstance with the specified policy- Parameters:
policy- the policy to use
Method Detail
setLogger
public void setLogger(ITXPLogger logger)
Sets the logger.- Parameters:
logger- The new logger instance.
newProcess
public ITXProcess newProcess()
Description copied from interface:ITXPCoordinatorCreates a new implementation specificITXProcessinstance and sets itself as coordinator.- Specified by:
newProcessin interfaceITXPCoordinator- Returns:
- an
ITXProcessinstance
ready
public void ready(ITXProcess process, ITXPNode node, ITXPNode.State nodeState)
Description copied from interface:ITXPCoordinatorCalled 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:
readyin interfaceITXPCoordinator- Parameters:
process- the processnode- the nodenodeState- the current state of the node
commit
public void commit(ITXProcess process) throws TXPException
Description copied from interface:ITXPCoordinatorCalled 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:
commitin interfaceITXPCoordinator- Parameters:
process- the process- Throws:
TXPException- a coordinator and policy dependent exception (today 1 of 3, more details later)
rollback
public void rollback(ITXProcess process) throws TXPException
Description copied from interface:ITXPCoordinatorCalled 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:
rollbackin interfaceITXPCoordinator- Parameters:
process- the process- Throws:
TXPException- a coordinator and policy dependent exception (today 1 of 3, more details later)
addMonitor
public void addMonitor(ITXPMonitor monitor)
Description copied from interface:ITXPCoordinatorAdds the specified TXP monitor. Monitors can be used for logging and monitoring processes under this coordinator's control.- Specified by:
addMonitorin interfaceITXPCoordinator- Parameters:
monitor- the monitor
removeMonitor
public void removeMonitor(ITXPMonitor monitor)
Description copied from interface:ITXPCoordinatorRemoves the specified TXP monitor.- Specified by:
removeMonitorin interfaceITXPCoordinator- Parameters:
monitor- The monitor.
getCoordinator
public ITXPCoordinator getCoordinator()
Description copied from interface:ITXPMonitorReturns the coordinator- Specified by:
getCoordinatorin interfaceITXPMonitor- Returns:
- the coordinator
onMonitorAdded
public void onMonitorAdded(ITXPMonitor monitor)
Description copied from interface:ITXPMonitorCalled when a monitor is added to the coordinator's monitor chain- Specified by:
onMonitorAddedin interfaceITXPMonitor- Parameters:
monitor- the monitor that got added
onMonitorRemoved
public void onMonitorRemoved(ITXPMonitor monitor)
Description copied from interface:ITXPMonitorCalled when a monitor is removed from the coordinator's monitor chain- Specified by:
onMonitorRemovedin interfaceITXPMonitor- Parameters:
monitor- the monitor that got removed
onBeganProcess
public void onBeganProcess(ITXProcess process)
Description copied from interface:ITXPMonitorCalled when a process created and associated with he controller- Specified by:
onBeganProcessin interfaceITXPMonitor- Parameters:
process- the process
onNodeAssociated
public void onNodeAssociated(ITXProcess process, ITXPNode node, ITXPNode.State returnedState)
Description copied from interface:ITXPMonitorCalled when a node is associated with a process- Specified by:
onNodeAssociatedin interfaceITXPMonitor- Parameters:
process- the processnode- the nodereturnedState- the returned node state
onNodeDisassociated
public void onNodeDisassociated(ITXProcess process, ITXPNode node)
Description copied from interface:ITXPMonitorCalled when a node is disassociated from a process- Specified by:
onNodeDisassociatedin interfaceITXPMonitor- Parameters:
process- the processnode- the node
onNodeReady
public void onNodeReady(ITXProcess process, ITXPNode node, ITXPNode.State returnedState)
Description copied from interface:ITXPMonitorCalled when a node has finished doing the work needed- Specified by:
onNodeReadyin interfaceITXPMonitor- Parameters:
process- the processnode- the nodereturnedState- the node state after attempting to do the work
onNodeTimeoutSignaled
public void onNodeTimeoutSignaled(ITXProcess process, ITXPNode node)
Description copied from interface:ITXPMonitorCalled when a node indicates it timed out waiting on the process.- Specified by:
onNodeTimeoutSignaledin interfaceITXPMonitor- Parameters:
process- the processnode- the node
onProcessTimeoutSignaled
public void onProcessTimeoutSignaled(ITXProcess process)
Description copied from interface:ITXPMonitorCalled when a process indicates it timed out waiting on the nodes- Specified by:
onProcessTimeoutSignaledin interfaceITXPMonitor- Parameters:
process- the process
onCommitInitiated
public void onCommitInitiated(ITXProcess process)
Description copied from interface:ITXPMonitorCalled when a process is called to attempt a commit- Specified by:
onCommitInitiatedin interfaceITXPMonitor- Parameters:
process- the process
onCommitCanceled
public void onCommitCanceled(ITXProcess process, TXPException reason)
Description copied from interface:ITXPMonitorCalled 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:
onCommitCanceledin interfaceITXPMonitor- Parameters:
process- the processreason- the exception thrown by the commit
onRollbackInitiated
public void onRollbackInitiated(ITXProcess process)
Description copied from interface:ITXPMonitorCalled when a process is called to attempt a rollback- Specified by:
onRollbackInitiatedin interfaceITXPMonitor- Parameters:
process- the process
onRollbackCanceled
public void onRollbackCanceled(ITXProcess process, TXPException reason)
Description copied from interface:ITXPMonitorCalled when the process aborts rolling back. This can happen if one or more nodes have not yet finished processing.- Specified by:
onRollbackCanceledin 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:ITXPMonitorCalled when the policy action is determined for a node that failed processing- Specified by:
onNodeReadyFailedPolicyActionin 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:ITXPMonitorCalled when the policy action is determined for a node that failed to commit- Specified by:
onNodeCommitFailedPolicyActionin interfaceITXPMonitor- Parameters:
process- the processnode- the nodeaction- the action
onNodeRollbackFailedPolicyAction
public void onNodeRollbackFailedPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action)
Description copied from interface:ITXPMonitorCalled when the policy action is determined for a node that failed to rollback- Specified by:
onNodeRollbackFailedPolicyActionin interfaceITXPMonitor- Parameters:
process- the processnode- the nodeaction- the action
onNodeTimeoutSignaledPolicyAction
public void onNodeTimeoutSignaledPolicyAction(ITXProcess process, ITXPNode node, ITXPPolicy.Action action)
Description copied from interface:ITXPMonitorCalled when the policy action is determined for a node that timed out waiting for completion.- Specified by:
onNodeTimeoutSignaledPolicyActionin interfaceITXPMonitor- Parameters:
process- the processnode- the nodeaction- the action
onProcessTimeoutSignaledPolicyAction
public void onProcessTimeoutSignaledPolicyAction(ITXProcess process, ITXPPolicy.Action action)
Description copied from interface:ITXPMonitorCalled when the policy action is determined for a process that timed out waiting for the nodes to do the work.- Specified by:
onProcessTimeoutSignaledPolicyActionin interfaceITXPMonitor- Parameters:
process- the processaction- the action
onProcessCreated
public void onProcessCreated(ITXProcess process)
Description copied from interface:ITXPMonitorCalled when the process is created.- Specified by:
onProcessCreatedin interfaceITXPMonitor- Parameters:
process- The process.
onProcessCompleted
public void onProcessCompleted(ITXProcess process)
Description copied from interface:ITXPMonitorCalled when a process has been completed (either committed or rolled back)- Specified by:
onProcessCompletedin interfaceITXPMonitor- Parameters:
process- The process.