Class ErrorFlyweight

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

public class ErrorFlyweight extends HeaderFlyweight
Flyweight for general Aeron network protocol error frame
    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
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 0  |R|                 Frame Length (varies)                       |
    +---------------+---------------+-------------------------------+
 4  |   Version     |     Flags     |         Type (=0x04)          |
    +---------------+---------------+-------------------------------+
 8  |                          Session ID                           |
    +---------------------------------------------------------------+
 12 |                           Stream ID                           |
    +---------------------------------------------------------------+
 16 |                          Receiver ID                          |
    |                                                               |
    +---------------------------------------------------------------+
 24 |                           Group Tag                           |
    |                                                               |
    +---------------------------------------------------------------+
 32 |                          Error Code                           |
    +---------------------------------------------------------------+
 36 |                     Error String Length                       |
    +---------------------------------------------------------------+
 40 |                         Error String                        ...
    +---------------------------------------------------------------+
    ...                                                             |
    +---------------------------------------------------------------+
 
Since:
1.47.0
  • Field Details

    • 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:
    • RECEIVER_ID_FIELD_OFFSET

      public static final int RECEIVER_ID_FIELD_OFFSET
      Offset in the frame at which the receiver-id field begins.
      See Also:
    • GROUP_TAG_FIELD_OFFSET

      public static final int GROUP_TAG_FIELD_OFFSET
      Offset in the frame at which the group-tag field begins.
      See Also:
    • ERROR_CODE_FIELD_OFFSET

      public static final int ERROR_CODE_FIELD_OFFSET
      Offset in the frame at which the error code field begins.
      See Also:
    • ERROR_STRING_FIELD_OFFSET

      public static final int ERROR_STRING_FIELD_OFFSET
      Offset in the frame at which the error string field begins. Specifically this will be the length of the string using the Agrona buffer standard of using 4 bytes for the length. Followed by the variable bytes for the string.
      See Also:
    • HEADER_LENGTH

      public static final int HEADER_LENGTH
      Length of the Error Header, i.e. all fixed size fields including length of the error message string but excluding its contents.
      See Also:
    • MAX_ERROR_MESSAGE_LENGTH

      public static final int MAX_ERROR_MESSAGE_LENGTH
      Maximum length that an error message can be. Can be short that this if configuration options have made the MTU smaller. The error message should be truncated to fit within a single MTU.
      See Also:
    • MAX_ERROR_FRAME_LENGTH

      public static final int MAX_ERROR_FRAME_LENGTH
      Maximum length of an error frame. Captures the maximum message length and the header length.
      See Also:
    • HAS_GROUP_ID_FLAG

      public static final int HAS_GROUP_ID_FLAG
      Flag to indicate that the group tag field is relevant, if not set the value should be ignored.
      See Also:
  • Constructor Details

    • ErrorFlyweight

      public ErrorFlyweight()
      Default constructor for the ErrorFlyweight so that it can be wrapped over a buffer later.
    • ErrorFlyweight

      public ErrorFlyweight(ByteBuffer buffer)
      Construct the ErrorFlyweight over an NIO ByteBuffer frame.
      Parameters:
      buffer - containing the frame.
    • ErrorFlyweight

      public ErrorFlyweight(UnsafeBuffer buffer)
      Construct the ErrorFlyweight over an UnsafeBuffer frame.
      Parameters:
      buffer - containing the frame.
  • Method Details

    • sessionId

      public int sessionId()
      The session-id for the stream.
      Returns:
      session-id for the stream.
    • sessionId

      public ErrorFlyweight sessionId(int sessionId)
      Set session-id for the stream.
      Parameters:
      sessionId - session-id for the stream.
      Returns:
      this for a fluent API.
    • streamId

      public int streamId()
      The stream-id for the stream.
      Returns:
      stream-id for the stream.
    • streamId

      public ErrorFlyweight streamId(int streamId)
      Set stream-id for the stream.
      Parameters:
      streamId - stream-id for the stream.
      Returns:
      this for a fluent API.
    • receiverId

      public long receiverId()
      The receiver-id for the stream.
      Returns:
      receiver-id for the stream.
    • receiverId

      public ErrorFlyweight receiverId(long receiverId)
      Set receiver-id for the stream.
      Parameters:
      receiverId - receiver-id for the stream.
      Returns:
      this for a fluent API.
    • groupTag

      public long groupTag()
      Get the group tag for the message.
      Returns:
      group tag for the message.
    • hasGroupTag

      public boolean hasGroupTag()
      Determines if this message has the group tag flag set.
      Returns:
      true if the flag is set false otherwise.
    • groupTag

      public ErrorFlyweight groupTag(Long groupTag)
      Set an optional group tag, null indicates the value should not be set. If non-null will set HAS_GROUP_TAG flag on the header. A null value will clear this flag and use a value of 0.
      Parameters:
      groupTag - optional group tag to be applied to this message.
      Returns:
      this for a fluent API.
    • errorCode

      public int errorCode()
      The error-code for the message.
      Returns:
      error-code for the message.
    • errorCode

      public ErrorFlyweight errorCode(int errorCode)
      Set error-code for the message.
      Parameters:
      errorCode - for the message.
      Returns:
      this for a fluent API.
    • errorMessage

      public String errorMessage()
      Get the error string for the message.
      Returns:
      the error string for the message.
    • errorMessage

      public ErrorFlyweight errorMessage(String errorMessage)
      Set the error string for the message.
      Parameters:
      errorMessage - the error string in UTF-8.
      Returns:
      this for a fluent API.
    • toString

      public String toString()
      Overrides:
      toString in class UnsafeBuffer