Package io.aeron.logbuffer
Class Header
java.lang.Object
io.aeron.logbuffer.Header
Represents the header of the data frame for accessing metadata fields.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuffer()TheDirectBuffercontaining the header.buffer(DirectBuffer buffer) TheDirectBuffercontaining the header.context()Context for storing state related to the context of the callback where the header is used.Assign context for storing state related to the context of the callback where the header is used.byteflags()The flags for this frame.intTotal amount of space occupied by this message when it is within the term buffer.voidfragmentedFrameLength(int fragmentedFrameLength) Total amount of space occupied by this message when it is within the term buffer.intThe total length of the frame including the header.intGet the initial term id this stream started at.initialTermId(int initialTermId) Get the initial term id this stream started at.intCalculates the offset of the frame immediately after this one.intoffset()The offset at which the frame begins in the buffer.offset(int offset) Set the offset at which the header begins in the buffer.longposition()Get the current position to which the image has advanced on reading this message.intThe 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.longGet the value stored in the reserve space at the end of a data frame header.intThe session ID to which the frame belongs.intstreamId()The stream ID to which the frame belongs.inttermId()The term ID to which the frame belongs.intThe offset in the term at which the frame begins.inttype()The type of the frame which should always beHeaderFlyweight.HDR_TYPE_DATA.
-
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
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 withcontext().
-
-
Method Details
-
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
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
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
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
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
TheDirectBuffercontaining the header.- Returns:
DirectBuffercontaining the header.
-
buffer
TheDirectBuffercontaining the header.- Parameters:
buffer-DirectBuffercontaining 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 beHeaderFlyweight.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 areDataHeaderFlyweight.BEGIN_FLAGandDataHeaderFlyweight.END_FLAG. A convenience flagDataHeaderFlyweight.BEGIN_AND_END_FLAGScan 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_ENDIANformat.- 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 beAeron.NULL_VALUE.- Returns:
- total fragmented length of this message or
Aeron.NULL_VALUEif not fragmented.
-