Package com.iizix.txp.impl
Class TXProcessImpl
java.lang.Object
com.iizix.txp.impl.TXProcessImpl
- All Implemented Interfaces:
- ITimeoutListener,- ITXProcess
Basic and crude (for now) 
ITXProcess implementation- Author:
- Freggle
- Nested Class Summary- Nested classes/interfaces inherited from interface com.iizix.txp.ITXProcess- ITXProcess.State
- Constructor SummaryConstructorsModifierConstructorDescription- protected- TXProcessImpl- (ITXPid pid, TXPCoordinatorImpl coordinator) Constructs a process.
- Method SummaryModifier and TypeMethodDescription- void- addAttribute- (String name, Object value) Adds a named attribute.- voidAssociate an atomic unit of work (a node) with this process.- void- commit()Called by the process logic/application (not the nodes!)to request that the transactional process gets committed.- getAttribute- (String name) Gets a named attribute.Return the process local policy- getPid()Gets the pid of his process- longGets the remaining time before timeout.- getState()Get the state of this process.- longReturns the nr of milliseconds this process waits for all nodes.- protected ITXProcessLogger- log()- voidCalled when timeout is reached.- void- ready- (ITXPNode node, ITXPNode.State nodeState) A node will call this method to signal its state after attempting to do the work.- removeAttribute- (String name) Removes a named attribute.- void- rollback()Called by the process logic/application (not the nodes) to request that the transactional process rolls back the work.- void- setStartTimeout- (long millisecs) Set the timeout time in milliseconds AND START THE TIMER!.- voidCalled by a node indicating it timed out waiting on the process.- void- useLocalPolicy- (ITXPPolicy policy) Have the coordinator use the specified local policy for this process.
- Constructor Details- TXProcessImplConstructs a process.- Parameters:
- pid- the pid for this process
 
 
- Method Details- useLocalPolicyDescription copied from interface:- ITXProcessHave the coordinator use the specified local policy for this process. To stop using a local policy specify- null.- Specified by:
- useLocalPolicyin interface- ITXProcess
- Parameters:
- policy- the policy
 
- getLocalPolicyDescription copied from interface:- ITXProcessReturn the process local policy- Specified by:
- getLocalPolicyin interface- ITXProcess
- Returns:
- the process local policy or null if none is used
 
- getPidDescription copied from interface:- ITXProcessGets the pid of his process- Specified by:
- getPidin interface- ITXProcess
- Returns:
- the pid
 
- getTimeoutpublic long getTimeout()Description copied from interface:- ITXProcessReturns the nr of milliseconds this process waits for all nodes. The timeout is applied when setStartTimeout() is called on the process. It is up to the coordinator (and maybe policy) to decide how to deal with a timeout but the nodes needs to be signalled that the process timed out and the defined behaviour for the node is to stop the work and wait for rollback unless the coordinator decides to CONTINUE or IGNORE the timeout.- Specified by:
- getTimeoutin interface- ITXProcess
- Returns:
- the timeout time in milliseconds
 
- associateDescription copied from interface:- ITXProcessAssociate an atomic unit of work (a node) with this process. This will cause a- begin()call in the node.- Specified by:
- associatein interface- ITXProcess
- Parameters:
- node- the node
 
- getStateDescription copied from interface:- ITXProcessGet the state of this process.- Specified by:
- getStatein interface- ITXProcess
- Returns:
- the state
 
- readyDescription copied from interface:- ITXProcessA node will call this method to signal its state after attempting to do the work.- Specified by:
- readyin interface- ITXProcess
- Parameters:
- node- the node
- nodeState- the current state of the node
 
- timeoutDescription copied from interface:- ITXProcessCalled by a node indicating it timed out waiting on the process. The process (and coordinator) must assume that the node abandoned the process and rolled back any change they made on behalf of it.- Specified by:
- timeoutin interface- ITXProcess
- Parameters:
- node- the node
 
- commitDescription copied from interface:- ITXProcessCalled by the process logic/application (not the nodes!)to request that the transactional process gets committed.- Specified by:
- commitin interface- ITXProcess
- Throws:
- TXPException- a coordinator and policy dependent exception (today 1 of 3, more details later)
 
- rollbackDescription copied from interface:- ITXProcessCalled by the process logic/application (not the nodes) to request that the transactional process rolls back the work.- Specified by:
- rollbackin interface- ITXProcess
- Throws:
- TXPException- a coordinator and policy dependent exception (today 1 of 3, more details later)
 
- addAttributeDescription copied from interface:- ITXProcessAdds a named attribute.- Specified by:
- addAttributein interface- ITXProcess
- Parameters:
- name- the attribute name
- value- the attribute value
 
- getAttributeDescription copied from interface:- ITXProcessGets a named attribute.- Specified by:
- getAttributein interface- ITXProcess
- Parameters:
- name- the attribute name
- Returns:
- the attribute value
 
- removeAttributeDescription copied from interface:- ITXProcessRemoves a named attribute.- Specified by:
- removeAttributein interface- ITXProcess
- Parameters:
- name- the attribute name
- Returns:
- the attribute value
 
- setStartTimeoutpublic void setStartTimeout- (long millisecs) Set the timeout time in milliseconds AND START THE TIMER!. -1L for indefinite (the default so you do not have to call it in that case) You should call this method after you associated all the nodes and all other initialization.- Specified by:
- setStartTimeoutin interface- ITXProcess
- Parameters:
- millisecs- the timeout time in milliseconds
 
- onTimeoutpublic void onTimeout()Description copied from interface:- ITimeoutListenerCalled when timeout is reached.- Specified by:
- onTimeoutin interface- ITimeoutListener
 
- log
- getRemainingTimepublic long getRemainingTime()Gets the remaining time before timeout. This value just keeps on counting, even when the timeout has occurred or the task is stopped.- Specified by:
- getRemainingTimein interface- ITXProcess
- Returns:
- A time in milliseconds >= zero indicating the remaining timeout time, or < zero if the task has timed out. The return value is Long.MAX_VALUEif the timeout is indefinite or never set.