Class MessageQueue
java.lang.Object
java.util.TimerTask
org.metricshub.ipmi.core.connection.queue.MessageQueue
- All Implemented Interfaces:
Runnable
Queues messages to send and checks for timeouts.
-
Constructor Summary
ConstructorsConstructorDescriptionMessageQueue
(Connection connection, int timeout, int minSequenceNumber, int maxSequenceNumber) -
Method Summary
Modifier and TypeMethodDescriptionint
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.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.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.int
getMessageRetries
(int tag) Deprecated.retries are no longer supported on the message levelint
getMessageSequenceNumber
(int tag) Returns the ID of theQueueElement
in the queue with the given tag.int
Returns valid session sequence number that cannot be used as a tag thoughint
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
tearDown()
Stops the MessageQueueMethods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
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
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
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.retries are no longer supported on the message levelReturns 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 theQueueElement
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.
-