Class MessageHandler

java.lang.Object
org.metricshub.ipmi.core.connection.MessageHandler
Direct Known Subclasses:
IpmiMessageHandler, SolMessageHandler

public abstract class MessageHandler extends Object
Class used for handling outgoing and incoming messages for a Connection.
  • Constructor Details

    • MessageHandler

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

    • sendMessage

      public int sendMessage(PayloadCoder payloadCoder, StateMachine stateMachine, int sessionId, boolean isOneWay) throws ConnectionException
      Attempts to send message encoded by given PayloadCoder to the remote system.
      Parameters:
      payloadCoder - instance of PayloadCoder that will produce payload for the message being sent.
      stateMachine - StateMachine for the currenr connection.
      sessionId - ID of the current session.
      isOneWay - flag indicating, if message is one way and we shouldn't await response, or it isn't and needs response from remote system. A one-way IPMI message is queued all the same, so that its tag stays reserved until its reply arrives or it times out, but its reply and its timeout are not reported (see takeTag(PayloadCoder, boolean)).
      Returns:
      sequence number of the sent message, or -1 when the queue is full
      Throws:
      ConnectionException - when could not send message due to some problems with connection
    • retryMessage

      public int retryMessage(int tag, StateMachine stateMachine, int sessionId) throws ConnectionException
      Attempts to retry sending message with given tag, assuming that this message exists in message queue.
      Parameters:
      tag - tag of the message that we want to resend
      stateMachine - StateMachine for the currenr connection.
      sessionId - ID of the current session.
      Returns:
      sequence number of the retried message (should be the same as original message tag) or -1 if no message was found in the queue.
      Throws:
      ConnectionException - when could not send message due to some problems with connection
    • handleIncomingMessage

      public void handleIncomingMessage(Ipmiv20Message message)
      Checks if received message is inside "sliding window range" and was not received yet, and if so, further processes the message in a implementation-specific way.
      Parameters:
      message - the message received from the BMC
    • setTimeout

      public void setTimeout(int timeout)
    • tearDown

      public void tearDown()
    • getSequenceNumber

      public int getSequenceNumber()
      Returns a sequence number for a message sent outside the queue (the Close Session request).
      Returns:
      a sequence number that no queued request holds