Package io.aeron.protocol
Class DataHeaderFlyweight
java.lang.Object
org.agrona.AbstractMutableDirectBuffer
org.agrona.concurrent.UnsafeBuffer
io.aeron.protocol.HeaderFlyweight
io.aeron.protocol.DataHeaderFlyweight
- All Implemented Interfaces:
Comparable<DirectBuffer>,AtomicBuffer,DirectBuffer,MutableDirectBuffer
Flyweight for Data Frame header of a message fragment.
Data Frame wiki page.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final shortBegin and End Flags.static final shortBegin, End, and EOS Flags.static final shortBegin, End, EOS, and Revoked Flags.static final short(B) - Fragment that Begins a message Flag.static final intOffset in the frame at which the data payload begins.static final longDefault value to be placed in the reserved value field.static final short(E) - Fragment that Ends a message Flag.static final short(S) - End of Stream (EOS) Flag for heartbeats after the publication is closed.static final intLength of the Data Header.static final intOffset in the frame at which the reserved value field begins.static final short(R) - Revoked Flag for heartbeats after the publication is revoked.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.static final intOffset in the frame at which the term-id field begins.static final intOffset in the frame at which the term-offset 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 which can later be used to wrap a frame.DataHeaderFlyweight(ByteBuffer buffer) Construct the flyweight over a frame.DataHeaderFlyweight(UnsafeBuffer buffer) Construct the flyweight over a frame. -
Method Summary
Modifier and TypeMethodDescriptionstatic UnsafeBuffercreateDefaultHeader(int sessionId, int streamId, int termId) Return an initialised default Data Frame Header.intReturn offset in buffer for data.static intfragmentLength(UnsafeBuffer termBuffer, int frameOffset) Get the fragment length field from the header.static booleanisEndOfStream(UnsafeBuffer packet) Does the data frame in the packet have the EOS flag set?static booleanisHeartbeat(UnsafeBuffer packet, int length) Is the frame at data frame at the beginning of packet a heartbeat message?static booleanisRevoked(UnsafeBuffer packet) Does the data frame in the packet have the REVOKED flag set?longGet the reserved value in LITTLE_ENDIAN format.reservedValue(long reservedValue) Set the reserved value in LITTLE_ENDIAN format.static longreservedValue(UnsafeBuffer termBuffer, int frameOffset) Get the reserved value field from the header.intGet the session-id field from the header.sessionId(int sessionId) Set the session-id field in the header.static intsessionId(UnsafeBuffer termBuffer, int frameOffset) Get the session-id field from the header.intstreamId()Get the stream-id field from the header.streamId(int streamId) Set the stream-id field in the header.static intstreamId(UnsafeBuffer termBuffer, int frameOffset) Get the stream-id field from the header.inttermId()Get the term-id field from the header.termId(int termId) Set the term-id field in the header.static inttermId(UnsafeBuffer termBuffer, int frameOffset) Get the term-id field from the header.intGet the term-offset field from the header.termOffset(int termOffset) Set the term-offset field in the header.static inttermOffset(UnsafeBuffer termBuffer, int frameOffset) Get the term-offset field from the header.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
-
HEADER_LENGTH
public static final int HEADER_LENGTHLength 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_FLAGSBegin 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_FLAGSBegin, 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_FLAGSBegin, End, EOS, and Revoked Flags.- See Also:
-
DEFAULT_RESERVE_VALUE
public static final long DEFAULT_RESERVE_VALUEDefault value to be placed in the reserved value field.- See Also:
-
TERM_OFFSET_FIELD_OFFSET
public static final int TERM_OFFSET_FIELD_OFFSETOffset in the frame at which the term-offset field begins.- See Also:
-
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:
-
TERM_ID_FIELD_OFFSET
public static final int TERM_ID_FIELD_OFFSETOffset in the frame at which the term-id field begins.- See Also:
-
RESERVED_VALUE_OFFSET
public static final int RESERVED_VALUE_OFFSETOffset in the frame at which the reserved value field begins.- See Also:
-
DATA_OFFSET
public static final int DATA_OFFSETOffset 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
Construct the flyweight over a frame.- Parameters:
buffer- containing the frame.
-
DataHeaderFlyweight
Construct the flyweight over a frame.- Parameters:
buffer- containing the frame.
-
-
Method Details
-
fragmentLength
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Return an initialised default Data Frame Header.- Parameters:
sessionId- for the headerstreamId- for the headertermId- for the header- Returns:
- byte array containing the header
-
toString
- Overrides:
toStringin classUnsafeBuffer
-