Class Header

java.lang.Object
io.aeron.logbuffer.Header

public final class Header extends Object
Represents the header of the data frame for accessing metadata fields.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Header(int initialTermId, int positionBitsToShift)
    Construct a header that references a buffer for the log.
    Header(int initialTermId, int positionBitsToShift, Object context)
    Construct a header that references a buffer for the log.
  • Method Summary

    Modifier and Type
    Method
    Description
    The DirectBuffer containing the header.
    The DirectBuffer containing the header.
    Context for storing state related to the context of the callback where the header is used.
    context(Object context)
    Assign context for storing state related to the context of the callback where the header is used.
    byte
    The flags for this frame.
    int
    Total amount of space occupied by this message when it is within the term buffer.
    void
    fragmentedFrameLength(int fragmentedFrameLength)
    Total amount of space occupied by this message when it is within the term buffer.
    int
    The total length of the frame including the header.
    int
    Get the initial term id this stream started at.
    initialTermId(int initialTermId)
    Get the initial term id this stream started at.
    int
    Calculates the offset of the frame immediately after this one.
    int
    The offset at which the frame begins in the buffer.
    offset(int offset)
    Set the offset at which the header begins in the buffer.
    long
    Get the current position to which the image has advanced on reading this message.
    int
    The number of times to left shift the term count to multiply by term length.
    positionBitsToShift(int positionBitsToShift)
    Set the number of times to left shift the term count to multiply by term length.
    long
    Get the value stored in the reserve space at the end of a data frame header.
    int
    The session ID to which the frame belongs.
    int
    The stream ID to which the frame belongs.
    int
    The term ID to which the frame belongs.
    int
    The offset in the term at which the frame begins.
    int
    The type of the frame which should always be HeaderFlyweight.HDR_TYPE_DATA.

    Methods inherited from class java.lang.Object

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

    • Header

      public Header(int initialTermId, int positionBitsToShift)
      Construct a header that references a buffer for the log.
      Parameters:
      initialTermId - this stream started at.
      positionBitsToShift - for calculating positions.
    • Header

      public Header(int initialTermId, int positionBitsToShift, Object context)
      Construct a header that references a buffer for the log.
      Parameters:
      initialTermId - this stream started at.
      positionBitsToShift - for calculating positions.
      context - for storing state when which can be accessed with context().
  • Method Details

    • context

      public Object context()
      Context for storing state related to the context of the callback where the header is used.
      Returns:
      context for storing state related to the context of the callback where the header is used.
    • context

      public Header context(Object context)
      Assign context for storing state related to the context of the callback where the header is used.
      Parameters:
      context - for storing state related to the context of the callback where the header is used.
      Returns:
      this for a fluent API.
    • position

      public long position()
      Get the current position to which the image has advanced on reading this message.
      Returns:
      the current position to which the image has advanced on reading this message.
    • positionBitsToShift

      public int positionBitsToShift()
      The number of times to left shift the term count to multiply by term length.
      Returns:
      number of times to left shift the term count to multiply by term length.
    • positionBitsToShift

      public Header positionBitsToShift(int positionBitsToShift)
      Set the number of times to left shift the term count to multiply by term length.
      Parameters:
      positionBitsToShift - number of times to left shift the term count to multiply by term length.
      Returns:
      this for a fluent API.
    • initialTermId

      public int initialTermId()
      Get the initial term id this stream started at.
      Returns:
      the initial term id this stream started at.
    • initialTermId

      public Header initialTermId(int initialTermId)
      Get the initial term id this stream started at.
      Parameters:
      initialTermId - the initial term id this stream started at.
      Returns:
      this for a fluent API.
    • offset

      public Header offset(int offset)
      Set the offset at which the header begins in the buffer.
      Parameters:
      offset - at which the header begins in the buffer.
      Returns:
      this for a fluent API.
    • offset

      public int offset()
      The offset at which the frame begins in the buffer.
      Returns:
      offset at which the frame begins in the buffer.
    • buffer

      public DirectBuffer buffer()
      The DirectBuffer containing the header.
      Returns:
      DirectBuffer containing the header.
    • buffer

      public Header buffer(DirectBuffer buffer)
      The DirectBuffer containing the header.
      Parameters:
      buffer - DirectBuffer containing the header.
      Returns:
      this for a fluent API.
    • frameLength

      public int frameLength()
      The total length of the frame including the header.
      Returns:
      the total length of the frame including the header.
    • sessionId

      public int sessionId()
      The session ID to which the frame belongs.
      Returns:
      the session ID to which the frame belongs.
    • streamId

      public int streamId()
      The stream ID to which the frame belongs.
      Returns:
      the stream ID to which the frame belongs.
    • termId

      public int termId()
      The term ID to which the frame belongs.
      Returns:
      the term ID to which the frame belongs.
    • termOffset

      public int termOffset()
      The offset in the term at which the frame begins.
      Returns:
      the offset in the term at which the frame begins.
    • nextTermOffset

      public int nextTermOffset()
      Calculates the offset of the frame immediately after this one.
      Returns:
      the offset of the next frame.
    • type

      public int type()
      The type of the frame which should always be HeaderFlyweight.HDR_TYPE_DATA.
      Returns:
      type of the frame which should always be HeaderFlyweight.HDR_TYPE_DATA.
    • flags

      public byte flags()
      The flags for this frame. Valid flags are DataHeaderFlyweight.BEGIN_FLAG and DataHeaderFlyweight.END_FLAG. A convenience flag DataHeaderFlyweight.BEGIN_AND_END_FLAGS can be used for both flags.
      Returns:
      the flags for this frame.
    • reservedValue

      public long reservedValue()
      Get the value stored in the reserve space at the end of a data frame header.

      Note: The value is in ByteOrder.LITTLE_ENDIAN format.

      Returns:
      the value stored in the reserve space at the end of a data frame header.
      See Also:
    • fragmentedFrameLength

      public void fragmentedFrameLength(int fragmentedFrameLength)
      Total amount of space occupied by this message when it is within the term buffer. When fragmented this will include the length of the header for each fragment. Used when doing reassembly of fragmented packets.
      Parameters:
      fragmentedFrameLength - total fragmented length of the message.
    • fragmentedFrameLength

      public int fragmentedFrameLength()
      Total amount of space occupied by this message when it is within the term buffer. When fragmented this will include the length of the header for each fragment. Used when doing reassembly of fragmented packets. If the packet is not fragmented this will be Aeron.NULL_VALUE.
      Returns:
      total fragmented length of this message or Aeron.NULL_VALUE if not fragmented.