public class LogBufferDescriptor
extends java.lang.Object
+----------------------------+ | Term 0 | +----------------------------+ | Term 1 | +----------------------------+ | Term 2 | +----------------------------+ | Log Meta Data | +----------------------------+
| Modifier and Type | Field and Description |
|---|---|
static int |
LOG_ACTIVE_PARTITION_INDEX_OFFSET
Offset within the log meta data where the active partition index is stored.
|
static int |
LOG_CORRELATION_ID_OFFSET
Offset within the log meta data which the
|
static int |
LOG_DEFAULT_FRAME_HEADER_LENGTH_OFFSET
Offset within the log meta data which the length field for the frame header is stored.
|
static int |
LOG_DEFAULT_FRAME_HEADER_MAX_LENGTH
Maximum length of a frame header.
|
static int |
LOG_DEFAULT_FRAME_HEADER_OFFSET
Offset at which the default frame headers begin.
|
static int |
LOG_INITIAL_TERM_ID_OFFSET
Offset within the log meta data where the active term id is stored.
|
static int |
LOG_META_DATA_LENGTH
Total length of the log meta data buffer in bytes.
|
static int |
LOG_META_DATA_SECTION_INDEX
Section index for which buffer contains the log meta data.
|
static int |
LOG_MTU_LENGTH_OFFSET
Offset within the log meta data which the MTU length is stored;
|
static int |
LOG_TIME_OF_LAST_SM_OFFSET
Offset within the log meta data where the time of last SM is stored.
|
static int |
PARTITION_COUNT
The number of partitions the log is divided into.
|
static int |
TERM_MIN_LENGTH
Minimum buffer length for a log term
|
static int |
TERM_TAIL_COUNTERS_OFFSET
Offset within the meta data where the tail values are stored.
|
| Constructor and Description |
|---|
LogBufferDescriptor() |
| Modifier and Type | Method and Description |
|---|---|
static int |
activePartitionIndex(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
Get the value of the active partition index used by the producer of this log.
|
static void |
activePartitionIndex(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int activePartitionIndex)
Set the value of the current active partition index for the producer using memory ordered semantics.
|
static void |
applyDefaultHeader(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
org.agrona.concurrent.UnsafeBuffer termBuffer,
int termOffset)
Apply the default header for a message in a term.
|
static void |
checkTermLength(int termLength)
Check that term length is valid and alignment is valid.
|
static long |
computeLogLength(int termLength)
Compute the total length of a log file given the term length.
|
static long |
computePosition(int activeTermId,
int termOffset,
int positionBitsToShift,
int initialTermId)
Compute the current position in absolute number of bytes.
|
static long |
computeTermBeginPosition(int activeTermId,
int positionBitsToShift,
int initialTermId)
Compute the current position in absolute number of bytes for the beginning of a term.
|
static int |
computeTermIdFromPosition(long position,
int positionBitsToShift,
int initialTermId)
Compute the term id from a position.
|
static int |
computeTermLength(long logLength)
Compute the term length based on the total length of the log.
|
static int |
computeTermOffsetFromPosition(long position,
int positionBitsToShift)
Compute the term offset from a given position.
|
static long |
correlationId(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
Get the value of the correlation ID for this log.
|
static void |
correlationId(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
long id)
Set the correlation ID used for this log.
|
static org.agrona.concurrent.UnsafeBuffer |
defaultFrameHeader(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
Get a wrapper around the default frame header from the log meta data.
|
static int |
indexByPosition(long position,
int positionBitsToShift)
Determine the partition index given a stream position.
|
static int |
indexByTerm(int initialTermId,
int activeTermId)
Determine the partition index to be used given the initial term and active term ids.
|
static int |
indexByTermCount(long termCount)
Determine the partition index based on number of terms that have passed.
|
static void |
initialiseTailWithTermId(org.agrona.concurrent.UnsafeBuffer logMetaData,
int partitionIndex,
int termId)
Set the initial value for the termId in the upper bits of the tail counter.
|
static int |
initialTermId(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
Get the value of the initial Term id used for this log.
|
static void |
initialTermId(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int initialTermId)
Set the initial term at which this log begins.
|
static int |
mtuLength(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
Get the value of the MTU length used for this log.
|
static void |
mtuLength(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int mtuLength)
Set the MTU length used for this log.
|
static int |
nextPartitionIndex(int currentIndex)
Rotate to the next partition in sequence for the term id.
|
static long |
rawTailVolatile(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
Get the raw value of the tail for the current active partition.
|
static long |
rawTailVolatile(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int partitionIndex)
Get the raw value of the tail for the given partition.
|
static void |
rotateLog(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int activePartitionIndex,
int termId)
Rotate the log and update the default headers for the new term.
|
static void |
storeDefaultFrameHeader(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
org.agrona.DirectBuffer defaultHeader)
Store the default frame header to the log meta data buffer.
|
static int |
termId(long rawTail)
Get the termId from a packed raw tail value.
|
static int |
termOffset(long rawTail,
long termLength)
Read the termOffset from a packed raw tail value.
|
static long |
timeOfLastStatusMessage(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
Get the value of the time of last SM in
System.currentTimeMillis(). |
static void |
timeOfLastStatusMessage(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
long timeInMillis)
Set the value of the time of last SM used by the producer of this log.
|
public static final int PARTITION_COUNT
public static final int LOG_META_DATA_SECTION_INDEX
public static final int TERM_MIN_LENGTH
public static final int TERM_TAIL_COUNTERS_OFFSET
public static final int LOG_ACTIVE_PARTITION_INDEX_OFFSET
public static final int LOG_TIME_OF_LAST_SM_OFFSET
public static final int LOG_INITIAL_TERM_ID_OFFSET
public static final int LOG_DEFAULT_FRAME_HEADER_LENGTH_OFFSET
public static final int LOG_MTU_LENGTH_OFFSET
public static final int LOG_CORRELATION_ID_OFFSET
public static final int LOG_DEFAULT_FRAME_HEADER_OFFSET
public static final int LOG_DEFAULT_FRAME_HEADER_MAX_LENGTH
public static final int LOG_META_DATA_LENGTH
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Tail Counter 0 | | | +---------------------------------------------------------------+ | Tail Counter 1 | | | +---------------------------------------------------------------+ | Tail Counter 2 | | | +---------------------------------------------------------------+ | Active Partition Index | +---------------------------------------------------------------+ | Cache Line Padding ... ... | +---------------------------------------------------------------+ | Time of Last Status Message | | | +---------------------------------------------------------------+ | Cache Line Padding ... ... | +---------------------------------------------------------------+ | Registration / Correlation ID | | | +---------------------------------------------------------------+ | Initial Term Id | +---------------------------------------------------------------+ | Default Frame Header Length | +---------------------------------------------------------------+ | MTU Length | +---------------------------------------------------------------+ | Cache Line Padding ... ... | +---------------------------------------------------------------+ | Default Frame Header ... ... | +---------------------------------------------------------------+
public static void checkTermLength(int termLength)
termLength - to be checked.java.lang.IllegalStateException - if the length is not as expected.public static int initialTermId(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
logMetaDataBuffer - containing the meta data.public static void initialTermId(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int initialTermId)
logMetaDataBuffer - containing the meta data.initialTermId - value to be set.public static int mtuLength(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
logMetaDataBuffer - containing the meta data.public static void mtuLength(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int mtuLength)
logMetaDataBuffer - containing the meta data.mtuLength - value to be set.public static long correlationId(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
logMetaDataBuffer - containing the meta data.public static void correlationId(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
long id)
logMetaDataBuffer - containing the meta data.id - value to be set.public static long timeOfLastStatusMessage(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
System.currentTimeMillis().logMetaDataBuffer - containing the meta data.public static void timeOfLastStatusMessage(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
long timeInMillis)
logMetaDataBuffer - containing the meta data.timeInMillis - value of the time of last SM in System.currentTimeMillis()public static int activePartitionIndex(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
logMetaDataBuffer - containing the meta data.public static void activePartitionIndex(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int activePartitionIndex)
logMetaDataBuffer - containing the meta data.activePartitionIndex - value of the active partition index used by the producer of this log.public static int nextPartitionIndex(int currentIndex)
currentIndex - partition indexpublic static int indexByTerm(int initialTermId,
int activeTermId)
initialTermId - at which the log buffer usage beganactiveTermId - that is in current usagepublic static int indexByTermCount(long termCount)
termCount - for the number of terms that have passed.public static int indexByPosition(long position,
int positionBitsToShift)
position - in the stream in bytes.positionBitsToShift - number of times to right shift the position for term countpublic static long computePosition(int activeTermId,
int termOffset,
int positionBitsToShift,
int initialTermId)
activeTermId - active term id.termOffset - in the term.positionBitsToShift - number of times to left shift the term countinitialTermId - the initial term id that this stream started onpublic static long computeTermBeginPosition(int activeTermId,
int positionBitsToShift,
int initialTermId)
activeTermId - active term id.positionBitsToShift - number of times to left shift the term countinitialTermId - the initial term id that this stream started onpublic static int computeTermIdFromPosition(long position,
int positionBitsToShift,
int initialTermId)
position - to calculate frompositionBitsToShift - number of times to right shift the positioninitialTermId - the initial term id that this stream started onpublic static int computeTermOffsetFromPosition(long position,
int positionBitsToShift)
position - to calculate frompositionBitsToShift - number of times to right shift the positionpublic static long computeLogLength(int termLength)
termLength - on which to base the calculation.public static int computeTermLength(long logLength)
logLength - the total length of the log.public static void storeDefaultFrameHeader(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
org.agrona.DirectBuffer defaultHeader)
logMetaDataBuffer - into which the default headers should be stored.defaultHeader - to be stored.java.lang.IllegalArgumentException - if the default header is larger than LOG_DEFAULT_FRAME_HEADER_MAX_LENGTHpublic static org.agrona.concurrent.UnsafeBuffer defaultFrameHeader(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
logMetaDataBuffer - containing the raw bytes for the default frame header.public static void applyDefaultHeader(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
org.agrona.concurrent.UnsafeBuffer termBuffer,
int termOffset)
logMetaDataBuffer - containing the default headers.termBuffer - to which the default header should be applied.termOffset - at which the default should be applied.public static void rotateLog(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int activePartitionIndex,
int termId)
logMetaDataBuffer - for the meta data.activePartitionIndex - current active index.termId - to be used in the default headers.public static void initialiseTailWithTermId(org.agrona.concurrent.UnsafeBuffer logMetaData,
int partitionIndex,
int termId)
logMetaData - contain the tail counter.partitionIndex - to be initialised.termId - to be set.public static int termId(long rawTail)
rawTail - containing the termIdpublic static int termOffset(long rawTail,
long termLength)
rawTail - containing the termOffset.termLength - that the offset cannot exceed.public static long rawTailVolatile(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer,
int partitionIndex)
logMetaDataBuffer - containing the tail counters.partitionIndex - for the tail counter.public static long rawTailVolatile(org.agrona.concurrent.UnsafeBuffer logMetaDataBuffer)
logMetaDataBuffer - containing the tail counters.Copyright © 2014 - 2016 Real Logic Ltd. All Rights Reserved.