Class DataHeaderFlyweight

All Implemented Interfaces:
Comparable<DirectBuffer>, AtomicBuffer, DirectBuffer, MutableDirectBuffer

public class DataHeaderFlyweight extends HeaderFlyweight
Flyweight for Data Frame header of a message fragment.

Data Frame wiki page.

  • Field Details

    • HEADER_LENGTH

      public static final int HEADER_LENGTH
      Length of the Data Header.
      See Also:
    • BEGIN_FLAG

      public static final short BEGIN_FLAG
      (B) - Fragment that Begins a message Flag.
      See Also:
    • END_FLAG

      public static final short END_FLAG
      (E) - Fragment that Ends a message Flag.
      See Also:
    • BEGIN_AND_END_FLAGS

      public static final short BEGIN_AND_END_FLAGS
      Begin and End Flags.
      See Also:
    • EOS_FLAG

      public static final short EOS_FLAG
      (S) - End of Stream (EOS) Flag for heartbeats after the publication is closed.
      See Also:
    • BEGIN_END_AND_EOS_FLAGS

      public static final short BEGIN_END_AND_EOS_FLAGS
      Begin, End, and EOS Flags.
      See Also:
    • REVOKED_FLAG

      public static final short REVOKED_FLAG
      (R) - Revoked Flag for heartbeats after the publication is revoked.
      See Also:
    • BEGIN_END_EOS_AND_REVOKED_FLAGS

      public static final short BEGIN_END_EOS_AND_REVOKED_FLAGS
      Begin, End, EOS, and Revoked Flags.
      See Also:
    • DEFAULT_RESERVE_VALUE

      public static final long DEFAULT_RESERVE_VALUE
      Default value to be placed in the reserved value field.
      See Also:
    • TERM_OFFSET_FIELD_OFFSET

      public static final int TERM_OFFSET_FIELD_OFFSET
      Offset in the frame at which the term-offset field begins.
      See Also:
    • SESSION_ID_FIELD_OFFSET

      public static final int SESSION_ID_FIELD_OFFSET
      Offset in the frame at which the session-id field begins.
      See Also:
    • STREAM_ID_FIELD_OFFSET

      public static final int STREAM_ID_FIELD_OFFSET
      Offset in the frame at which the stream-id field begins.
      See Also:
    • TERM_ID_FIELD_OFFSET

      public static final int TERM_ID_FIELD_OFFSET
      Offset in the frame at which the term-id field begins.
      See Also:
    • RESERVED_VALUE_OFFSET

      public static final int RESERVED_VALUE_OFFSET
      Offset in the frame at which the reserved value field begins.
      See Also:
    • DATA_OFFSET

      public static final int DATA_OFFSET
      Offset in the frame at which the data payload begins.
      See Also:
  • Constructor Details

    • DataHeaderFlyweight

      public DataHeaderFlyweight()
      Default constructor which can later be used to wrap a frame.
    • DataHeaderFlyweight

      public DataHeaderFlyweight(UnsafeBuffer buffer)
      Construct the flyweight over a frame.
      Parameters:
      buffer - containing the frame.
    • DataHeaderFlyweight

      public DataHeaderFlyweight(ByteBuffer buffer)
      Construct the flyweight over a frame.
      Parameters:
      buffer - containing the frame.
  • Method Details

    • fragmentLength

      public static int fragmentLength(UnsafeBuffer termBuffer, int frameOffset)
      Get the fragment length field from the header.
      Parameters:
      termBuffer - containing the header.
      frameOffset - in the buffer where the header starts.
      Returns:
      the fragment length field from the header.
    • isHeartbeat

      public static boolean isHeartbeat(UnsafeBuffer packet, int length)
      Is the frame at data frame at the beginning of packet a heartbeat message?
      Parameters:
      packet - containing the data frame.
      length - of the data frame.
      Returns:
      true if a heartbeat otherwise false.
    • isEndOfStream

      public static boolean isEndOfStream(UnsafeBuffer packet)
      Does the data frame in the packet have the EOS flag set?
      Parameters:
      packet - containing the data frame.
      Returns:
      true if the EOS flag is set otherwise false.
    • isRevoked

      public static boolean isRevoked(UnsafeBuffer packet)
      Does the data frame in the packet have the REVOKED flag set?
      Parameters:
      packet - containing the data frame
      Returns:
      true if the REVOKED flag is set otherwise false.
    • sessionId

      public int sessionId()
      Get the session-id field from the header.
      Returns:
      the session-id field from the header.
    • sessionId

      public static int sessionId(UnsafeBuffer termBuffer, int frameOffset)
      Get the session-id field from the header.
      Parameters:
      termBuffer - containing the header.
      frameOffset - in the buffer where the header starts.
      Returns:
      the session-id field from the header.
    • sessionId

      public DataHeaderFlyweight sessionId(int sessionId)
      Set the session-id field in the header.
      Parameters:
      sessionId - value to set.
      Returns:
      this for a fluent API.
    • streamId

      public int streamId()
      Get the stream-id field from the header.
      Returns:
      the stream-id field from the header.
    • streamId

      public static int streamId(UnsafeBuffer termBuffer, int frameOffset)
      Get the stream-id field from the header.
      Parameters:
      termBuffer - containing the header.
      frameOffset - in the buffer where the header starts.
      Returns:
      the stream-id field from the header.
    • streamId

      public DataHeaderFlyweight streamId(int streamId)
      Set the stream-id field in the header.
      Parameters:
      streamId - value to set.
      Returns:
      this for a fluent API.
    • termId

      public int termId()
      Get the term-id field from the header.
      Returns:
      the term-id field from the header.
    • termId

      public static int termId(UnsafeBuffer termBuffer, int frameOffset)
      Get the term-id field from the header.
      Parameters:
      termBuffer - containing the header.
      frameOffset - in the buffer where the header starts.
      Returns:
      the term-id field from the header.
    • termId

      public DataHeaderFlyweight termId(int termId)
      Set the term-id field in the header.
      Parameters:
      termId - value to set.
      Returns:
      this for a fluent API.
    • termOffset

      public int termOffset()
      Get the term-offset field from the header.
      Returns:
      the term-offset field from the header.
    • termOffset

      public static int termOffset(UnsafeBuffer termBuffer, int frameOffset)
      Get the term-offset field from the header.
      Parameters:
      termBuffer - containing the header.
      frameOffset - in the buffer where the header starts.
      Returns:
      the term-offset field from the header.
    • termOffset

      public DataHeaderFlyweight termOffset(int termOffset)
      Set the term-offset field in the header.
      Parameters:
      termOffset - value to set.
      Returns:
      this for a fluent API.
    • reservedValue

      public long reservedValue()
      Get the reserved value in LITTLE_ENDIAN format.
      Returns:
      value of the reserved value.
    • reservedValue

      public static long reservedValue(UnsafeBuffer termBuffer, int frameOffset)
      Get the reserved value field from the header.
      Parameters:
      termBuffer - containing the header.
      frameOffset - in the buffer where the header starts.
      Returns:
      the reserved value field from the header.
    • reservedValue

      public DataHeaderFlyweight reservedValue(long reservedValue)
      Set the reserved value in LITTLE_ENDIAN format.
      Parameters:
      reservedValue - to be stored
      Returns:
      flyweight
    • dataOffset

      public int dataOffset()
      Return offset in buffer for data.
      Returns:
      offset of data in the buffer.
    • createDefaultHeader

      public static UnsafeBuffer createDefaultHeader(int sessionId, int streamId, int termId)
      Return an initialised default Data Frame Header.
      Parameters:
      sessionId - for the header
      streamId - for the header
      termId - for the header
      Returns:
      byte array containing the header
    • toString

      public String toString()
      Overrides:
      toString in class UnsafeBuffer