public class FrameDescriptor
extends java.lang.Object
All messages are logged in frames that have a minimum header layout as follows plus a reserve then the encoded message follows:
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| Frame Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------------------------+ | Version |B|E| Flags | Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------------------------+ |R| Term Offset | +-+-------------------------------------------------------------+ | Additional Fields ... ... | +---------------------------------------------------------------+ | Encoded Message ... ... | +---------------------------------------------------------------+
The (B)egin and (E)nd flags are used for message fragmentation. R is for reserved bit. Both (B)egin and (E)nd flags are set for a message that does not span frames.
Modifier and Type | Field and Description |
---|---|
static byte |
BEGIN_FRAG_FLAG
Beginning fragment of a frame.
|
static byte |
END_FRAG_FLAG
End fragment of a frame.
|
static int |
FLAGS_OFFSET
Offset within a frame at which the flags field begins
|
static int |
FRAME_ALIGNMENT
Alignment as a multiple of bytes for each frame.
|
static int |
MAX_MESSAGE_LENGTH
Set a pragmatic maximum message length regardless of term length to encourage better design.
|
static int |
PADDING_FRAME_TYPE
Padding frame type to indicate the message should be ignored.
|
static int |
TERM_ID_OFFSET
Offset within a frame at which the term id field begins
|
static int |
TERM_OFFSET
Offset within a frame at which the term offset field begins
|
static int |
TYPE_OFFSET
Offset within a frame at which the type field begins
|
static byte |
UNFRAGMENTED
End fragment of a frame.
|
static int |
VERSION_OFFSET
Offset within a frame at which the version field begins
|
Constructor and Description |
---|
FrameDescriptor() |
Modifier and Type | Method and Description |
---|---|
static int |
computeMaxMessageLength(int termLength)
Compute the maximum supported message length for a buffer of given termLength.
|
static int |
flagsOffset(int termOffset)
The buffer offset at which the flags field begins.
|
static byte |
frameFlags(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset)
Get the flags field for a frame.
|
static void |
frameFlags(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset,
byte flags)
Write the flags field for a frame.
|
static int |
frameLength(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset)
Get the length of a frame from the header.
|
static void |
frameLengthOrdered(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset,
int frameLength)
Write the length header for a frame in a memory ordered fashion.
|
static int |
frameLengthVolatile(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset)
Get the length of a frame from the header as a volatile read.
|
static void |
frameTermId(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset,
int termId)
Write the term id field for a frame.
|
static void |
frameTermOffset(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset)
Write the term offset field for a frame.
|
static int |
frameType(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset)
Read the type of of the frame from header.
|
static void |
frameType(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset,
int type)
Write the type field for a frame.
|
static int |
frameVersion(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset)
Read the type of of the frame from header.
|
static boolean |
isPaddingFrame(org.agrona.concurrent.UnsafeBuffer buffer,
int termOffset)
Is the frame starting at the termOffset a padding frame at the end of a buffer?
|
static int |
lengthOffset(int termOffset)
The buffer offset at which the length field begins.
|
static int |
termIdOffset(int termOffset)
The buffer offset at which the term id field begins.
|
static int |
termOffsetOffset(int termOffset)
The buffer offset at which the term offset field begins.
|
static int |
typeOffset(int termOffset)
The buffer offset at which the type field begins.
|
static int |
versionOffset(int termOffset)
The buffer offset at which the version field begins.
|
public static final int MAX_MESSAGE_LENGTH
public static final int FRAME_ALIGNMENT
public static final byte BEGIN_FRAG_FLAG
public static final byte END_FRAG_FLAG
public static final byte UNFRAGMENTED
public static final int VERSION_OFFSET
public static final int FLAGS_OFFSET
public static final int TYPE_OFFSET
public static final int TERM_OFFSET
public static final int TERM_ID_OFFSET
public static final int PADDING_FRAME_TYPE
public static int computeMaxMessageLength(int termLength)
termLength
- of the log buffer.public static int lengthOffset(int termOffset)
termOffset
- at which the frame begins.public static int versionOffset(int termOffset)
termOffset
- at which the frame begins.public static int flagsOffset(int termOffset)
termOffset
- at which the frame begins.public static int typeOffset(int termOffset)
termOffset
- at which the frame begins.public static int termOffsetOffset(int termOffset)
termOffset
- at which the frame begins.public static int termIdOffset(int termOffset)
termOffset
- at which the frame begins.public static int frameVersion(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset)
buffer
- containing the frame.termOffset
- at which a frame begins.public static byte frameFlags(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset)
buffer
- containing the frame.termOffset
- at which a frame begins.public static int frameType(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset)
buffer
- containing the frame.termOffset
- at which a frame begins.public static boolean isPaddingFrame(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset)
buffer
- containing the frame.termOffset
- at which a frame begins.public static int frameLength(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset)
buffer
- containing the frame.termOffset
- at which a frame begins.public static int frameLengthVolatile(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset)
buffer
- containing the frame.termOffset
- at which a frame begins.public static void frameLengthOrdered(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset, int frameLength)
buffer
- containing the frame.termOffset
- at which a frame begins.frameLength
- field to be set for the frame.public static void frameType(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset, int type)
buffer
- containing the frame.termOffset
- at which a frame begins.type
- type value for the frame.public static void frameFlags(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset, byte flags)
buffer
- containing the frame.termOffset
- at which a frame begins.flags
- value for the frame.public static void frameTermOffset(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset)
buffer
- containing the frame.termOffset
- at which a frame begins.public static void frameTermId(org.agrona.concurrent.UnsafeBuffer buffer, int termOffset, int termId)
buffer
- containing the frame.termOffset
- at which a frame begins.termId
- value for the frame.Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.