Class RecordDescriptor

java.lang.Object
org.agrona.concurrent.ringbuffer.RecordDescriptor

public final class RecordDescriptor extends Object
Description of the record structure for message framing in the a RingBuffer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Alignment as a multiple of bytes for each record.
    static final int
    Header length made up of fields for length, type, and then the encoded message.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    checkTypeId(int msgTypeId)
    Check that and message id is in the valid range.
    static int
    encodedMsgOffset(int recordOffset)
    The offset from the beginning of a record at which the encoded message begins.
    static int
    lengthOffset(int recordOffset)
    The offset from the beginning of a record at which the message length field begins.
    static int
    typeOffset(int recordOffset)
    The offset from the beginning of a record at which the message type field begins.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HEADER_LENGTH

      public static final int HEADER_LENGTH
      Header length made up of fields for length, type, and then the encoded message.

      Writing of a positive record length signals the message recording is complete.

         0                   1                   2                   3
         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                           Length                              |
        +---------------------------------------------------------------+
        |                            Type                               |
        +---------------------------------------------------------------+
        |                       Encoded Message                        ...
       ...                                                              |
        +---------------------------------------------------------------+
       
      See Also:
    • ALIGNMENT

      public static final int ALIGNMENT
      Alignment as a multiple of bytes for each record.
      See Also:
  • Constructor Details

    • RecordDescriptor

      private RecordDescriptor()
  • Method Details

    • lengthOffset

      public static int lengthOffset(int recordOffset)
      The offset from the beginning of a record at which the message length field begins.
      Parameters:
      recordOffset - beginning index of the record.
      Returns:
      offset from the beginning of a record at which the type field begins.
    • typeOffset

      public static int typeOffset(int recordOffset)
      The offset from the beginning of a record at which the message type field begins.
      Parameters:
      recordOffset - beginning index of the record.
      Returns:
      offset from the beginning of a record at which the type field begins.
    • encodedMsgOffset

      public static int encodedMsgOffset(int recordOffset)
      The offset from the beginning of a record at which the encoded message begins.
      Parameters:
      recordOffset - beginning index of the record.
      Returns:
      offset from the beginning of a record at which the encoded message begins.
    • checkTypeId

      public static void checkTypeId(int msgTypeId)
      Check that and message id is in the valid range.
      Parameters:
      msgTypeId - to be checked.
      Throws:
      IllegalArgumentException - if the id is not in the valid range.