Class MessageQueue

java.lang.Object
java.util.TimerTask
org.metricshub.ipmi.core.connection.queue.MessageQueue
All Implemented Interfaces:
Runnable

public class MessageQueue extends TimerTask
Queues messages to send and checks for timeouts.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MessageQueue(Connection connection, int timeout, int minSequenceNumber, int maxSequenceNumber)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    add(PayloadCoder request)
    Adds request to the queue and generates the tag.
    boolean
    containsId(int sequenceNumber)
    Checks if queue contains message with the given sequence number.
    Returns message with the given sequence number from the queue or null if no message with the given tag is currently in the queue.
    int
    Returns index of the message with the given sequence number from the queue or -1 if no message with the given tag is currently in the queue.
    int
    Deprecated.
    retries are no longer supported on the message level
    int
    Returns the ID of the QueueElement in the queue with the given tag.
    int
    Returns valid session sequence number that cannot be used as a tag though
    int
     
    void
    remove(int tag)
    Removes message with the given tag from the queue.
    void
    removeAt(int index)
    Removes message from queue at given index.
    void
    run()
    TimerTask runner - periodically checks queue for timed out messages.
    void
    setTimeout(int timeout)
     
    void
    Stops the MessageQueue

    Methods inherited from class java.util.TimerTask

    cancel, scheduledExecutionTime

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MessageQueue

      public MessageQueue(Connection connection, int timeout, int minSequenceNumber, int maxSequenceNumber)
  • Method Details

    • getTimeout

      public int getTimeout()
    • setTimeout

      public void setTimeout(int timeout)
    • tearDown

      public void tearDown()
      Stops the MessageQueue
    • add

      public int add(PayloadCoder request)
      Adds request to the queue and generates the tag.
      Returns:
      Sequence number of the message if it was added to the queue, -1 otherwise. The tag used to identify message is equal to that value.
    • remove

      public void remove(int tag)
      Removes message with the given tag from the queue.
    • removeAt

      public void removeAt(int index)
      Removes message from queue at given index.
      Parameters:
      index -
    • containsId

      public boolean containsId(int sequenceNumber)
      Checks if queue contains message with the given sequence number.
    • getSequenceNumber

      public int getSequenceNumber()
      Returns valid session sequence number that cannot be used as a tag though
    • getMessageFromQueue

      public PayloadCoder getMessageFromQueue(int tag)
      Returns message with the given sequence number from the queue or null if no message with the given tag is currently in the queue.
    • getMessageIndexFromQueue

      public int getMessageIndexFromQueue(int tag)
      Returns index of the message with the given sequence number from the queue or -1 if no message with the given tag is currently in the queue.
    • getMessageRetries

      @Deprecated public int getMessageRetries(int tag)
      Deprecated.
      retries are no longer supported on the message level
      Returns number of retries that were performed on message tagged with tag or -1 if no such message can be found in the queue.
    • getMessageSequenceNumber

      public int getMessageSequenceNumber(int tag)
      Returns the ID of the QueueElement in the queue with the given tag.
      Parameters:
      tag - Tag of the message to find
    • run

      public void run()
      TimerTask runner - periodically checks queue for timed out messages.
      Specified by:
      run in interface Runnable
      Specified by:
      run in class TimerTask