Package io.aeron.protocol
Class ErrorFlyweight
java.lang.Object
org.agrona.AbstractMutableDirectBuffer
org.agrona.concurrent.UnsafeBuffer
io.aeron.protocol.HeaderFlyweight
io.aeron.protocol.ErrorFlyweight
- All Implemented Interfaces:
Comparable<DirectBuffer>,AtomicBuffer,DirectBuffer,MutableDirectBuffer
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intOffset in the frame at which the error code field begins.static final intOffset in the frame at which the error string field begins.static final intOffset in the frame at which the group-tag field begins.static final intFlag to indicate that the group tag field is relevant, if not set the value should be ignored.static final intLength of the Error Header, i.e.static final intMaximum length of an error frame.static final intMaximum length that an error message can be.static final intOffset in the frame at which the receiver-id field begins.static final intOffset in the frame at which the session-id field begins.static final intOffset in the frame at which the stream-id field begins.Fields inherited from class io.aeron.protocol.HeaderFlyweight
CURRENT_VERSION, FLAGS_FIELD_OFFSET, FRAME_LENGTH_FIELD_OFFSET, HDR_TYPE_ATS_DATA, HDR_TYPE_ATS_SETUP, HDR_TYPE_ATS_SM, HDR_TYPE_DATA, HDR_TYPE_ERR, HDR_TYPE_EXT, HDR_TYPE_NAK, HDR_TYPE_PAD, HDR_TYPE_RES, HDR_TYPE_RSP_SETUP, HDR_TYPE_RTTM, HDR_TYPE_SETUP, HDR_TYPE_SM, MIN_HEADER_LENGTH, TYPE_FIELD_OFFSET, VERSION_FIELD_OFFSETFields inherited from class org.agrona.concurrent.UnsafeBuffer
ALIGNMENT, DISABLE_BOUNDS_CHECKS_PROP_NAME, SHOULD_BOUNDS_CHECKFields inherited from class org.agrona.AbstractMutableDirectBuffer
addressOffset, byteArray, capacityFields inherited from interface org.agrona.concurrent.AtomicBuffer
STRICT_ALIGNMENT_CHECKS, STRICT_ALIGNMENT_CHECKS_PROP_NAMEFields inherited from interface org.agrona.DirectBuffer
DISABLE_ARRAY_CONTENT_PRINTOUT_PROP_NAME, STR_HEADER_LEN -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for the ErrorFlyweight so that it can be wrapped over a buffer later.ErrorFlyweight(ByteBuffer buffer) Construct the ErrorFlyweight over an NIO ByteBuffer frame.ErrorFlyweight(UnsafeBuffer buffer) Construct the ErrorFlyweight over an UnsafeBuffer frame. -
Method Summary
Modifier and TypeMethodDescriptionintThe error-code for the message.errorCode(int errorCode) Set error-code for the message.Get the error string for the message.errorMessage(String errorMessage) Set the error string for the message.longgroupTag()Get the group tag for the message.Set an optional group tag, null indicates the value should not be set.booleanDetermines if this message has the group tag flag set.longThe receiver-id for the stream.receiverId(long receiverId) Set receiver-id for the stream.intThe session-id for the stream.sessionId(int sessionId) Set session-id for the stream.intstreamId()The stream-id for the stream.streamId(int streamId) Set stream-id for the stream.toString()Methods inherited from class io.aeron.protocol.HeaderFlyweight
appendFlagsAsChars, flags, flags, flagsToChars, frameLength, frameLength, headerType, headerType, version, versionMethods inherited from class org.agrona.concurrent.UnsafeBuffer
addIntOpaque, addIntOrdered, addIntRelease, addLongOpaque, addLongOrdered, addLongRelease, byteBuffer, compareAndExchangeInt, compareAndExchangeLong, compareAndSetInt, compareAndSetLong, ensureCapacity, getAndAddInt, getAndAddLong, getAndSetInt, getAndSetLong, getByteVolatile, getCharVolatile, getIntAcquire, getIntOpaque, getIntVolatile, getLongAcquire, getLongOpaque, getLongVolatile, getShortVolatile, isExpandable, putByteVolatile, putCharVolatile, putIntOpaque, putIntOrdered, putIntRelease, putIntVolatile, putLongOpaque, putLongOrdered, putLongRelease, putLongVolatile, putShortVolatile, verifyAlignment, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrapAdjustmentMethods inherited from class org.agrona.AbstractMutableDirectBuffer
addressOffset, boundsCheck, boundsCheck0, byteArray, capacity, checkLimit, compareTo, equals, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getChar, getChar, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringUtf8, getStringUtf8, getStringUtf8, getStringWithoutLengthAscii, getStringWithoutLengthAscii, getStringWithoutLengthUtf8, hashCode, parseIntAscii, parseLongAscii, parseNaturalIntAscii, parseNaturalLongAscii, putByte, putBytes, putBytes, putBytes, putBytes, putBytes, putChar, putChar, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putIntAscii, putLong, putLong, putLongAscii, putNaturalIntAscii, putNaturalIntAsciiFromEnd, putNaturalLongAscii, putNaturalPaddedIntAscii, putShort, putShort, putStringAscii, putStringAscii, putStringAscii, putStringAscii, putStringUtf8, putStringUtf8, putStringUtf8, putStringUtf8, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthUtf8, setMemoryMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.agrona.DirectBuffer
addressOffset, boundsCheck, byteArray, capacity, checkLimit, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getChar, getChar, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringUtf8, getStringUtf8, getStringUtf8, getStringWithoutLengthAscii, getStringWithoutLengthAscii, getStringWithoutLengthUtf8, parseIntAscii, parseLongAscii, parseNaturalIntAscii, parseNaturalLongAsciiMethods inherited from interface org.agrona.MutableDirectBuffer
putByte, putBytes, putBytes, putBytes, putBytes, putBytes, putChar, putChar, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putIntAscii, putLong, putLong, putLongAscii, putNaturalIntAscii, putNaturalIntAsciiFromEnd, putNaturalLongAscii, putNaturalPaddedIntAscii, putShort, putShort, putStringAscii, putStringAscii, putStringAscii, putStringAscii, putStringUtf8, putStringUtf8, putStringUtf8, putStringUtf8, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthUtf8, setMemory
-
Field Details
-
SESSION_ID_FIELD_OFFSET
public static final int SESSION_ID_FIELD_OFFSETOffset in the frame at which the session-id field begins.- See Also:
-
STREAM_ID_FIELD_OFFSET
public static final int STREAM_ID_FIELD_OFFSETOffset in the frame at which the stream-id field begins.- See Also:
-
RECEIVER_ID_FIELD_OFFSET
public static final int RECEIVER_ID_FIELD_OFFSETOffset in the frame at which the receiver-id field begins.- See Also:
-
GROUP_TAG_FIELD_OFFSET
public static final int GROUP_TAG_FIELD_OFFSETOffset in the frame at which the group-tag field begins.- See Also:
-
ERROR_CODE_FIELD_OFFSET
public static final int ERROR_CODE_FIELD_OFFSETOffset in the frame at which the error code field begins.- See Also:
-
ERROR_STRING_FIELD_OFFSET
public static final int ERROR_STRING_FIELD_OFFSETOffset 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_LENGTHLength 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_LENGTHMaximum 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_LENGTHMaximum 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_FLAGFlag 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
Construct the ErrorFlyweight over an NIO ByteBuffer frame.- Parameters:
buffer- containing the frame.
-
ErrorFlyweight
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
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
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
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:
trueif the flag is set false otherwise.
-
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
Set error-code for the message.- Parameters:
errorCode- for the message.- Returns:
- this for a fluent API.
-
errorMessage
Get the error string for the message.- Returns:
- the error string for the message.
-
errorMessage
Set the error string for the message.- Parameters:
errorMessage- the error string in UTF-8.- Returns:
- this for a fluent API.
-
toString
- Overrides:
toStringin classUnsafeBuffer
-