Package com.iizix.txp
Interface ITXProcess
- All Known Implementing Classes:
TXProcessImpl
public interface ITXProcess
The
TXPProcess interface abstracts a transactional process. The interface is used by nodes. Coordinator and process implementations may use proprietary interfaces to communicate with each other.- Author:
- Freggle
Nested Class Summary
Nested ClassesMethod Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String name, Object value) Adds a named attribute.voidAssociate an atomic unit of work (a node) with this process.voidcommit()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 policygetPid()Gets the pid of his processlongGets the remaining time before timeout.getState()Get the state of this process.longReturns the nr of milliseconds this process waits for all nodes.voidready(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.voidrollback()Called by the process logic/application (not the nodes) to request that the transactional process rolls back the work.voidsetStartTimeout(long timeout) Tells the process to wait timeout ms for the work to be done.voidCalled by a node indicating it timed out waiting on the process.voiduseLocalPolicy(ITXPPolicy policy) Have the coordinator use the specified local policy for this process.
Method Details
useLocalPolicy
Have the coordinator use the specified local policy for this process. To stop using a local policy specifynull.- Parameters:
policy- the policy
getLocalPolicy
ITXPPolicy getLocalPolicy()Return the process local policy- Returns:
- the process local policy or null if none is used
getPid
ITXPid getPid()Gets the pid of his process- Returns:
- the pid
getTimeout
long getTimeout()Returns 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.- Returns:
- the timeout time in milliseconds
associate
Associate an atomic unit of work (a node) with this process. This will cause abegin()call in the node.- Parameters:
node- the node
setStartTimeout
void setStartTimeout(long timeout) Tells the process to wait timeout ms for the work to be done.- Parameters:
timeout- Timeout in milliseconds.
getRemainingTime
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.- 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.
getState
ITXProcess.State getState()Get the state of this process.- Returns:
- the state
ready
A node will call this method to signal its state after attempting to do the work.- Parameters:
node- the nodenodeState- the current state of the node
timeout
Called 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.- Parameters:
node- the node
commit
Called by the process logic/application (not the nodes!)to request that the transactional process gets committed.- Throws:
TXPException- a coordinator and policy dependent exception (today 1 of 3, more details later)
rollback
Called by the process logic/application (not the nodes) to request that the transactional process rolls back the work.- Throws:
TXPException- a coordinator and policy dependent exception (today 1 of 3, more details later)
addAttribute
Adds a named attribute.- Parameters:
name- the attribute namevalue- the attribute value
getAttribute
Gets a named attribute.- Parameters:
name- the attribute name- Returns:
- the attribute value
removeAttribute
Removes a named attribute.- Parameters:
name- the attribute name- Returns:
- the attribute value