Package org.agrona.concurrent.broadcast
Class RecordDescriptor
java.lang.Object
org.agrona.concurrent.broadcast.RecordDescriptor
Description of the structure for a record in the broadcast buffer.
All messages are stored in records with the following format.
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R| Length | +-+-------------------------------------------------------------+ | Type | +---------------------------------------------------------------+ | Encoded Message ... ... | +---------------------------------------------------------------+
(R) bits are reserved.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Length of the record header in bytes.static final int
Offset within the record at which the record length field begins.static final int
Message type is padding to prevent fragmentation in the buffer.static final int
Alignment as a multiple of bytes for each record.static final int
Offset within the record at which the message type field begins. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
calculateMaxMessageLength
(int capacity) Calculate the maximum supported message length for a buffer of given capacity.static void
checkTypeId
(int msgTypeId) Check that and message id is in the valid range.static int
lengthOffset
(int recordOffset) The buffer offset at which the message length field begins.static int
msgOffset
(int recordOffset) The buffer offset at which the encoded message begins.static int
typeOffset
(int recordOffset) The buffer offset at which the message type field begins.
-
Field Details
-
PADDING_MSG_TYPE_ID
public static final int PADDING_MSG_TYPE_IDMessage type is padding to prevent fragmentation in the buffer.- See Also:
-
LENGTH_OFFSET
public static final int LENGTH_OFFSETOffset within the record at which the record length field begins.- See Also:
-
TYPE_OFFSET
public static final int TYPE_OFFSETOffset within the record at which the message type field begins.- See Also:
-
HEADER_LENGTH
public static final int HEADER_LENGTHLength of the record header in bytes.- See Also:
-
RECORD_ALIGNMENT
public static final int RECORD_ALIGNMENTAlignment as a multiple of bytes for each record.- See Also:
-
-
Constructor Details
-
RecordDescriptor
private RecordDescriptor()
-
-
Method Details
-
calculateMaxMessageLength
public static int calculateMaxMessageLength(int capacity) Calculate the maximum supported message length for a buffer of given capacity.- Parameters:
capacity
- of the log buffer.- Returns:
- the maximum supported size for a message.
-
lengthOffset
public static int lengthOffset(int recordOffset) The buffer offset at which the message length field begins.- Parameters:
recordOffset
- at which the frame begins.- Returns:
- the offset at which the message length field begins.
-
typeOffset
public static int typeOffset(int recordOffset) The buffer offset at which the message type field begins.- Parameters:
recordOffset
- at which the frame begins.- Returns:
- the offset at which the message type field begins.
-
msgOffset
public static int msgOffset(int recordOffset) The buffer offset at which the encoded message begins.- Parameters:
recordOffset
- at which the frame begins.- Returns:
- the offset 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.
-