Class RollbackStack

  • All Implemented Interfaces:
    IRollbackStack
    Direct Known Subclasses:
    RollbackStack

    public class RollbackStack
    extends java.lang.Object
    implements IRollbackStack
    A package internal class to manage the rollback stack.

    Since there is no persistent stack class, the rollback stack is implemented with two queues, optimized for pushing onto the stack (poping from the stack is slower).

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  RollbackStack.IRollbackStackDelegate
      Delegate methods for the rollback stack, giving clients of the stack control over its behavior.
    • Constructor Summary

      Constructors 
      Constructor Description
      RollbackStack​(java.io.File commandsFile)
      Constructor for a rollback stack that uses queue1File and queue2File for the persistent queues.
      RollbackStack​(java.io.File commandsFile, org.apache.log4j.Logger operationLog)  
    • Constructor Detail

      • RollbackStack

        public RollbackStack​(java.io.File commandsFile)
        Constructor for a rollback stack that uses queue1File and queue2File for the persistent queues.
        Parameters:
        commandsFile - File for a persistent queue
      • RollbackStack

        public RollbackStack​(java.io.File commandsFile,
                             org.apache.log4j.Logger operationLog)
    • Method Detail

      • getSize

        public int getSize()
        The size of the rollback stack
      • rollbackAll

        public void rollbackAll()
        Rollback any commands that have been executed. Rollback is done in the reverse order of execution.
      • rollbackAll

        public void rollbackAll​(RollbackStack.IRollbackStackDelegate delegate)
        Rollback any commands that have been executed. Rollback is done in the reverse order of execution.
      • discard

        public void discard()
        Throws away the persistent stack.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getCommandsFile

        public java.io.File getCommandsFile()
        Internal getter for clients that need to serialize the rollback stack. Use this method with caution since it exposes implementation details.
      • setLockedState

        public void setLockedState​(boolean lockedState)
        Description copied from interface: IRollbackStack
        Sets the locked state of this rollback stack. Changing this state to true results in creating or deleting the marker file. If already in a desired state - does nothing.
        Specified by:
        setLockedState in interface IRollbackStack
      • isLockedState

        public boolean isLockedState()
        Description copied from interface: IRollbackStack
        Returns whether this rollback stack is in locked state (i.e. it cannot execute any rollback actions)
        Specified by:
        isLockedState in interface IRollbackStack