Class OperationQueue


  • public class OperationQueue
    extends Object
    Queue of operations to be performed when operating in MANUAL FlushMode. This queue will typically contain operations on second class objects, such as Collections or Maps. They are queued in the order they are invoked by the user. The queue will contain all operations to be performed for an ExecutionContext. There are two methods for processing them, one processing all (for use in the future when we support that mode in full), and one that processes all for a particular SCO (backing store).
    • Field Detail

    • Constructor Detail

      • OperationQueue

        public OperationQueue()
    • Method Detail

      • enqueue

        public void enqueue​(Operation oper)
        Method to add the specified operation to the operation queue.
        Parameters:
        oper - Operation
      • log

        public void log()
        Convenience method to log the current operation queue.
      • clear

        public void clear()
      • getOperations

        public List<Operation> getOperations()
        Method to provide access to inspect the queued operations. The returned list is unmodifiable.
        Returns:
        The queued operations
      • removeOperations

        public void removeOperations​(List<Operation> removedOps)
      • performAll

        public void performAll()
        Method to perform all operations queued. Those operations are then removed from the queue.
      • performAll

        public void performAll​(Store store,
                               DNStateManager sm)
        Method to perform all operations queued for the specified StateManager and backing store. Those operations are then removed from the queue.
        Parameters:
        store - The backing store
        sm - StateManager
      • clearPersistDeleteUpdateOperations

        public void clearPersistDeleteUpdateOperations()
      • processOperationsForNoBackingStoreSCOs

        public void processOperationsForNoBackingStoreSCOs​(ExecutionContext ec)
        Method to process all SCO operations where the SCOs don't use a backing store. This will check for add+remove/remove+add and perform cascade delete as appropriate. It will then remove the SCO operations from the queue. It doesn't actually process the queued operations since when you have no backing store there is nothing to do.
        Parameters:
        ec - ExecutionContext
      • isAddFollowedByRemoveOnSameSCO

        protected static boolean isAddFollowedByRemoveOnSameSCO​(Store store,
                                                                DNStateManager sm,
                                                                Operation currentOper,
                                                                ListIterator<Operation> listIter)
        Convenience optimisation checker to return if the current operation is ADD of an element that is immediately REMOVED. Always leaves the iterator at the same position as starting
        Parameters:
        store - The backing store
        sm - The StateManager
        currentOper - The current operation
        listIter - The iterator of operations
        Returns:
        Whether this is an ADD that has a REMOVE of the same element immediately after
      • isRemoveFollowedByAddOnSameSCO

        protected static boolean isRemoveFollowedByAddOnSameSCO​(Store store,
                                                                DNStateManager sm,
                                                                Operation currentOper,
                                                                ListIterator<Operation> listIter)
        Convenience optimisation checker to return if the current operation is REMOVE of an element that is immediately ADDed. Always leaves the iterator at the same position as starting
        Parameters:
        store - The backing store
        sm - The StateManager
        currentOper - The current operation
        listIter - The iterator of operations
        Returns:
        Whether this is a REMOVE that has an ADD of the same element immediately after
      • isPutFollowedByRemoveOnSameSCO

        protected static boolean isPutFollowedByRemoveOnSameSCO​(Store store,
                                                                DNStateManager sm,
                                                                Operation currentOper,
                                                                ListIterator<Operation> listIter)
        Convenience optimisation checker to return if the current operation is PUT of a key that is immediately REMOVED. Always leaves the iterator at the same position as starting
        Parameters:
        store - The backing store
        sm - The StateManager
        currentOper - The current operation
        listIter - The iterator of operations
        Returns:
        Whether this is a PUT that has a REMOVE of the same key immediately after