Class InMemoryQueue<T extends Queueable>

java.lang.Object
com.epam.fixengine.storage.queue.InMemoryQueue<T>
All Implemented Interfaces:
Queue<T>
Direct Known Subclasses:
MMFPersistentInMemoryQueue, PersistentInMemoryQueue

public class InMemoryQueue<T extends Queueable> extends Object implements Queue<T>
Memory queue implementation.
See Also:
  • Field Details

  • Constructor Details

    • InMemoryQueue

      @Deprecated public InMemoryQueue()
      Deprecated.
    • InMemoryQueue

      public InMemoryQueue(com.epam.fixengine.configuration.Configuration conf)
      Create the memory queue.
  • Method Details

    • initialize

      public void initialize()
      Description copied from interface: Queue
      Initializes queue. That includes restore of previously saved queue content for persistent queues.
      Specified by:
      initialize in interface Queue<T extends Queueable>
      See Also:
    • size

      public int size()
      Description copied from interface: Queue
      Returns current queue size.
      Specified by:
      size in interface Queue<T extends Queueable>
      Returns:
      queue size
      See Also:
    • totalSize

      public int totalSize()
      Description copied from interface: Queue
      Returns current total queue size. The total size of the usual queue and the OutOfTurn queue.
      Specified by:
      totalSize in interface Queue<T extends Queueable>
      Returns:
      queue size
      See Also:
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Queue
      Checks if queue is currently empty.
      Specified by:
      isEmpty in interface Queue<T extends Queueable>
      Returns:
      true if empty
      See Also:
    • isAllEmpty

      public boolean isAllEmpty()
      Specified by:
      isAllEmpty in interface Queue<T extends Queueable>
    • add

      public boolean add(T object)
      Description copied from interface: Queue
      Add object to the queue.
      Specified by:
      add in interface Queue<T extends Queueable>
      Parameters:
      object - the element
      Returns:
      true if element added successfully.
      See Also:
    • addOutOfTurn

      public boolean addOutOfTurn(T object)
      Description copied from interface: Queue
      Add object to the queue out of turn.
      Specified by:
      addOutOfTurn in interface Queue<T extends Queueable>
      Parameters:
      object - the element
      Returns:
      true if element added successfully.
      See Also:
    • poll

      public T poll()
      Description copied from interface: Queue
      Poll object from the queue (doesn't remove it from queue yet!).
      Specified by:
      poll in interface Queue<T extends Queueable>
      Returns:
      the head of this queue, or null if this queue is empty
      See Also:
    • setOutOfTurnOnlyMode

      public void setOutOfTurnOnlyMode(boolean newMode)
      Description copied from interface: Queue
      Out of turn messages only mode.
      Specified by:
      setOutOfTurnOnlyMode in interface Queue<T extends Queueable>
      Parameters:
      newMode - the mode
      See Also:
    • isOutOfTurnOnlyMode

      public boolean isOutOfTurnOnlyMode()
      Description copied from interface: Queue
      Out of turn messages only mode.
      Specified by:
      isOutOfTurnOnlyMode in interface Queue<T extends Queueable>
    • clearOutOfTurn

      public void clearOutOfTurn(Consumer<T> elementConsumer)
      Description copied from interface: Queue
      Removes the elements which were added by addOutOfTurn.
      Specified by:
      clearOutOfTurn in interface Queue<T extends Queueable>
      Parameters:
      elementConsumer - callback for each removed message. It is called after removing next message.
      See Also:
    • commit

      public void commit()
      Description copied from interface: Queue
      Removes polled object from the queue. If nothing was polled - throws IllegalStateException
      Specified by:
      commit in interface Queue<T extends Queueable>
      See Also:
    • clear

      public void clear()
      Description copied from interface: Queue
      Clears the queue.
      Specified by:
      clear in interface Queue<T extends Queueable>
      See Also:
    • shutdown

      public void shutdown()
      Description copied from interface: Queue
      Gracefully shutdowns queue.
      Specified by:
      shutdown in interface Queue<T extends Queueable>
      See Also:
    • isShutdown

      protected boolean isShutdown()
      Returns true if queue is shutdown.
    • isApplicationCommit

      public boolean isApplicationCommit()
      Return true if last commit was application.
    • notifyAllApplication

      public void notifyAllApplication()
      Description copied from interface: Queue
      Notify a new application message exists.

      The methods works only if turn "mode on" is off.

      Specified by:
      notifyAllApplication in interface Queue<T extends Queueable>
      See Also:
    • notifyAllSession

      public void notifyAllSession()
      Description copied from interface: Queue
      Notify a new session message exists.
      Specified by:
      notifyAllSession in interface Queue<T extends Queueable>
    • toArray

      public Queueable[] toArray()
      Description copied from interface: Queue
      Return all objects in the queue as array. Method has no impact on poll / commit operations.
      Specified by:
      toArray in interface Queue<T extends Queueable>
      Returns:
      array of Queueable