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 Classes
    Modifier and Type
    Interface
    Description
    static enum 
    The process state.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAttribute(String name, Object value)
    Adds a named attribute.
    void
    Associate an atomic unit of work (a node) with this process.
    void
    Called by the process logic/application (not the nodes!)to request that the transactional process gets committed.
    Gets a named attribute.
    Return the process local policy
    Gets the pid of his process
    long
    Gets the remaining time before timeout.
    Get the state of this process.
    long
    Returns the nr of milliseconds this process waits for all nodes.
    void
    ready(ITXPNode node, ITXPNode.State nodeState)
    A node will call this method to signal its state after attempting to do the work.
    Removes a named attribute.
    void
    Called by the process logic/application (not the nodes) to request that the transactional process rolls back the work.
    void
    setStartTimeout(long timeout)
    Tells the process to wait timeout ms for the work to be done.
    void
    Called by a node indicating it timed out waiting on the process.
    void
    Have the coordinator use the specified local policy for this process.
  • Method Details

    • useLocalPolicy

      void useLocalPolicy(ITXPPolicy policy)
      Have the coordinator use the specified local policy for this process. To stop using a local policy specify null.
      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 a begin() 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_VALUE if 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 node
      nodeState - 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 TXPException
      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

      void rollback() throws TXPException
      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

      void addAttribute(String name, Object value)
      Adds a named attribute.
      Parameters:
      name - the attribute name
      value - the attribute value
    • getAttribute

      Object getAttribute(String name)
      Gets a named attribute.
      Parameters:
      name - the attribute name
      Returns:
      the attribute value
    • removeAttribute

      Object removeAttribute(String name)
      Removes a named attribute.
      Parameters:
      name - the attribute name
      Returns:
      the attribute value