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 int
Alignment as a multiple of bytes for each record.static final int
Header length made up of fields for length, type, and then the encoded message. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkTypeId
(int msgTypeId) Check that and message id is in the valid range.static int
encodedMsgOffset
(int recordOffset) The offset from the beginning of a record at which the encoded message begins.static int
lengthOffset
(int recordOffset) The offset from the beginning of a record at which the message length field begins.static int
typeOffset
(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:
-
-
Constructor Details
-
RecordDescriptor
private RecordDescriptor()
-
-
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.
-