Package org.agrona.concurrent.ringbuffer
Class RecordDescriptor
java.lang.Object
org.agrona.concurrent.ringbuffer.RecordDescriptor
Description of the record structure for message framing in the a
RingBuffer.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAlignment as a multiple of bytes for each record.static final intHeader length made up of fields for length, type, and then the encoded message. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckTypeId(int msgTypeId) Check that and message id is in the valid range.static intencodedMsgOffset(int recordOffset) The offset from the beginning of a record at which the encoded message begins.static intlengthOffset(int recordOffset) The offset from the beginning of a record at which the message length field begins.static inttypeOffset(int recordOffset) The offset from the beginning of a record at which the message type field begins.
-
Field Details
-
HEADER_LENGTH
public static final int HEADER_LENGTHHeader length made up of fields for length, type, and then the encoded message.Writing of a positive record length signals the message recording is complete.
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length | +---------------------------------------------------------------+ | Type | +---------------------------------------------------------------+ | Encoded Message ... ... | +---------------------------------------------------------------+
- See Also:
-
ALIGNMENT
public static final int ALIGNMENTAlignment as a multiple of bytes for each record.- See Also:
-
-
Method Details
-
lengthOffset
public static int lengthOffset(int recordOffset) The offset from the beginning of a record at which the message length field begins.- Parameters:
recordOffset- beginning index of the record.- Returns:
- offset from the beginning of a record at which the type field begins.
-
typeOffset
public static int typeOffset(int recordOffset) The offset from the beginning of a record at which the message type field begins.- Parameters:
recordOffset- beginning index of the record.- Returns:
- offset from the beginning of a record at which the type field begins.
-
encodedMsgOffset
public static int encodedMsgOffset(int recordOffset) The offset from the beginning of a record at which the encoded message begins.- Parameters:
recordOffset- beginning index of the record.- Returns:
- offset from the beginning of a record at which the encoded message begins.
-
checkTypeId
public static void checkTypeId(int msgTypeId) Check that and message id is in the valid range.- Parameters:
msgTypeId- to be checked.- Throws:
IllegalArgumentException- if the id is not in the valid range.
-