Package org.agrona.concurrent.broadcast
Class RecordDescriptor
- java.lang.Object
-
- org.agrona.concurrent.broadcast.RecordDescriptor
-
public final class RecordDescriptor extends java.lang.Object
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
Fields Modifier and Type Field Description static int
HEADER_LENGTH
Length of the record header in bytes.static int
LENGTH_OFFSET
Offset within the record at which the record length field begins.static int
PADDING_MSG_TYPE_ID
Message type is padding to prevent fragmentation in the buffer.static int
RECORD_ALIGNMENT
Alignment as a multiple of bytes for each record.static int
TYPE_OFFSET
Offset within the record at which the message type field begins.
-
Constructor Summary
Constructors Modifier Constructor Description private
RecordDescriptor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 Detail
-
PADDING_MSG_TYPE_ID
public static final int PADDING_MSG_TYPE_ID
Message type is padding to prevent fragmentation in the buffer.- See Also:
- Constant Field Values
-
LENGTH_OFFSET
public static final int LENGTH_OFFSET
Offset within the record at which the record length field begins.- See Also:
- Constant Field Values
-
TYPE_OFFSET
public static final int TYPE_OFFSET
Offset within the record at which the message type field begins.- See Also:
- Constant Field Values
-
HEADER_LENGTH
public static final int HEADER_LENGTH
Length of the record header in bytes.- See Also:
- Constant Field Values
-
RECORD_ALIGNMENT
public static final int RECORD_ALIGNMENT
Alignment as a multiple of bytes for each record.- See Also:
- Constant Field Values
-
-
Method Detail
-
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:
java.lang.IllegalArgumentException
- if the id is not in the valid range.
-
-