Class CounterMessageFlyweight

java.lang.Object
io.aeron.command.CorrelatedMessageFlyweight
io.aeron.command.CounterMessageFlyweight

public class CounterMessageFlyweight extends CorrelatedMessageFlyweight
Message to denote a new counter.

Note: Layout should be SBE 2.0 compliant so that the label length is aligned.

See Also:
  • Constructor Details

    • CounterMessageFlyweight

      public CounterMessageFlyweight()
  • Method Details

    • wrap

      public CounterMessageFlyweight wrap(MutableDirectBuffer buffer, int offset)
      Wrap the buffer at a given offset for updates.
      Overrides:
      wrap in class CorrelatedMessageFlyweight
      Parameters:
      buffer - to wrap.
      offset - at which the message begins.
      Returns:
      this for a fluent API.
    • typeId

      public int typeId()
      Get type id field.
      Returns:
      type id field.
    • typeId

      public CounterMessageFlyweight typeId(int typeId)
      Set counter type id field.
      Parameters:
      typeId - field value.
      Returns:
      this for a fluent API.
    • keyBufferOffset

      public int keyBufferOffset()
      Relative offset of the key buffer.
      Returns:
      relative offset of the key buffer.
    • keyBufferLength

      public int keyBufferLength()
      Length of the key buffer in bytes.
      Returns:
      length of key buffer in bytes.
    • keyBuffer

      public CounterMessageFlyweight keyBuffer(DirectBuffer keyBuffer, int keyOffset, int keyLength)
      Fill the key buffer.
      Parameters:
      keyBuffer - containing the optional key for the counter.
      keyOffset - within the keyBuffer at which the key begins.
      keyLength - of the key in the keyBuffer.
      Returns:
      this for a fluent API.
    • labelBufferOffset

      public int labelBufferOffset()
      Relative offset of label buffer.
      Returns:
      relative offset of label buffer.
    • labelBufferLength

      public int labelBufferLength()
      Length of label buffer in bytes.
      Returns:
      length of label buffer in bytes.
    • labelBuffer

      public CounterMessageFlyweight labelBuffer(DirectBuffer labelBuffer, int labelOffset, int labelLength)
      Fill the label buffer.
      Parameters:
      labelBuffer - containing the mandatory label for the counter.
      labelOffset - within the labelBuffer at which the label begins.
      labelLength - of the label in the labelBuffer.
      Returns:
      this for a fluent API.
    • label

      public CounterMessageFlyweight label(String label)
      Fill the label.
      Parameters:
      label - for the counter.
      Returns:
      this for a fluent API.
    • length

      public int length()
      Get the length of the current message.

      NB: must be called after the data is written in order to be accurate.

      Returns:
      the length of the current message
    • validateLength

      public void validateLength(int msgTypeId, int length)
      Validate buffer length is long enough for message.
      Overrides:
      validateLength in class CorrelatedMessageFlyweight
      Parameters:
      msgTypeId - type of message.
      length - of message in bytes to validate.
    • computeLength

      public static int computeLength(int keyLength, int labelLength)
      Compute the length of the command message given key and label length.
      Parameters:
      keyLength - to be appended.
      labelLength - to be appended.
      Returns:
      the length of the command message given key and label length.
    • toString

      public String toString()
      Overrides:
      toString in class Object