Package com.iizix.txp

Interface ITXPNode

    • Method Detail

      • getPid

        ITXPid getPid()
        Gets the pid of this node.
        Returns:
        the pid
      • getState

        ITXPNode.State getState()
        Returns the state of the node.
        Returns:
        the state
      • isIdempotent

        boolean isIdempotent()
        Asks if the node is idempotent. Idempotent means f(f(x)) = f(x). For instance: if the node turns on a light, turning it on again has the same result: the light is on.
        Returns:
        true if this node is idempotent, false if not
      • getTimeout

        long getTimeout()
        Gets the time in milliseconds this node will wait for a commit() or rollback() call after it is ready.
        Returns:
        the timeout in milliseconds
      • begin

        ITXPNode.State begin​(ITXProcess process,
                             ITXPid pid)
        Notifies the node it got associated with a transactional process. The node should set up its local transaction context and set and respond with either ITXPNode.State.WORKING or ITXPNode.State.FAILED depending on its state.
        Parameters:
        process - the process
        pid - the pid for this node of the process
        Returns:
        the state of the node
      • forget

        void forget​(ITXProcess process)
        Notifies the node it got disassociated from the process ie it can abort, rollback (if needed) and forget about the process.
        Parameters:
        process - the process
      • timeout

        void timeout​(ITXProcess process)
        Called by a process to indicate it timed out waiting for this node. The node should abandon the work and wait for rollback or return READ_ONLY if it can.
        Parameters:
        process - the process that timed out
      • processTimeout

        void processTimeout​(ITXProcess process)
        Called by a process to indicate it timed out waiting for all nodes to complete the work. The node should abandon the work if it can and wait for rollback or return READ_ONLY if it can.
        Parameters:
        process - the process that timed out
      • hasTimedOut

        boolean hasTimedOut()
        Check if timeout has been called
        Returns:
        true if timeout has been called
      • hasProcessTimedOut

        boolean hasProcessTimedOut()
        Check if processTimeout has been called
        Returns:
        try if processTimeout has been called
      • undo

        ITXPNode.State undo​(ITXProcess process)
        Instructs the node to undo the committed work. The node should set and respond with either ITXPNode.State.OK, ITXPNode.State.FAILED or ITXPNode.State.UNABLE depending on its state. This is of course the 'crux'. It is the implementation that may or may not be able to undo something. For instance. if the node is a JDBC transaction it may know how to perform a compensating transaction; or not.
        Parameters:
        process - the process
        Returns:
        the state of the node
      • recover

        ITXPNode.State recover​(ITXProcess process)
        This method instructs an node to recover a process after some sort of system failure. In effect this means restoring the state of the ITXPNode to the last known state with regards to the specified process. The node should set and respond with either ITXPNode.State.OK, ITXPNode.State.FAILED or ITXPNode.State.UNABLE depending on its state. To be able to do this the node needs to log its state durably and use the Processes Pid as a key.
        Parameters:
        process - the process
        Returns:
        the state of the node