Package com.iizix.txp
Interface ITXProcess
- All Known Implementing Classes:
TXProcessImpl
public interface ITXProcessTheTXPProcessinterface 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 Classes Modifier and Type Interface Description static classITXProcess.StateThe process state.
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddAttribute(java.lang.String name, java.lang.Object value)Adds a named attribute.voidassociate(ITXPNode node)Associate 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.java.lang.ObjectgetAttribute(java.lang.String name)Gets a named attribute.ITXPPolicygetLocalPolicy()Return the process local policyITXPidgetPid()Gets the pid of his processlonggetRemainingTime()Gets the remaining time before timeout.ITXProcess.StategetState()Get the state of this process.longgetTimeout()Returns 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.java.lang.ObjectremoveAttribute(java.lang.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.voidtimeout(ITXPNode node)Called 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 Detail
useLocalPolicy
void useLocalPolicy(ITXPPolicy policy)
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
void associate(ITXPNode node)
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
void ready(ITXPNode node, ITXPNode.State nodeState)
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
void timeout(ITXPNode node)
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
void commit() throws TXPExceptionCalled 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
void rollback() throws TXPExceptionCalled 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
void addAttribute(java.lang.String name, java.lang.Object value)Adds a named attribute.- Parameters:
name- the attribute namevalue- the attribute value
getAttribute
java.lang.Object getAttribute(java.lang.String name)
Gets a named attribute.- Parameters:
name- the attribute name- Returns:
- the attribute value
removeAttribute
java.lang.Object removeAttribute(java.lang.String name)
Removes a named attribute.- Parameters:
name- the attribute name- Returns:
- the attribute value