Package io.aeron.logbuffer
Class LogBufferDescriptor
java.lang.Object
io.aeron.logbuffer.LogBufferDescriptor
Layout description for log buffers which contains partitions of terms with associated term metadata,
plus ending with overall log metadata.
+----------------------------+ | Term 0 | +----------------------------+ | Term 1 | +----------------------------+ | Term 2 | +----------------------------+ | Log Meta Data | +----------------------------+
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intOffset within the log metadata where the active partition index is stored.static final intOffset within the log metadata where the count of active transports is stored.static final byteValue for thetypefield to indicate a concurrent publication.static final byteValue for thetypefield to indicate an exclusive publication.static final byteValue for thetypefield to indicate a subscription.static final intOffset within the log metadata which the correlation id is stored.static final intOffset within the log metadata which the length field for the frame header is stored.static final intMaximum length of a frame header.static final intOffset at which the default frame headers begin.static final intOffset within the log metadata where the position of the End of Stream is stored.static final intOffset within the log metadata where the entity tag is stored.static final intOffset within the log metadata where the group is stored.static final intOffset within the log metadata where the active term id is stored.static final intOffset within the log metadata where whether the log is connected or not is stored.static final intOffset within the log metadata where the 'publication revoked' status is indicated.static final intOffset within the log metadata where is-response is stored.static final intOffset within the log metadata where the linger timeout ns is stored.static final intOffset within the log metadata where the max resend is stored.static final intTotal length of the log metadata buffer in bytes.static final intSection index for which buffer contains the log metadata.static final intOffset within the log metadata which the MTU length is stored.static final intOffset within the log metadata where the OS default length for the socket receive buffer is stored.static final intOffset within the log metadata where the OS default length for the socket send buffer is stored.static final intOffset within the log metadata where the OS maximum length for the socket receive buffer is stored.static final intOffset within the log metadata where the OS maximum length for the socket send buffer is stored.static final intOffset within the log metadata which the page size is stored.static final intOffset within the log metadata where the publication window length is stored.static final intOffset within the log metadata where the receiver window length is stored.static final intOffset within the log metadata where the rejoin property is stored.static final intOffset within the log metadata where the reliable property is stored.static final intOffset within the log metadata where the response correlation id is stored.static final intOffset within the log metadata where the signal-eos is stored.static final intOffset within the log metadata where the socket receive buffer length is stored.static final intOffset within the log metadata where the socket send buffer length is stored.static final intOffset within the log metadata where the sparse property is stored.static final intOffset within the log metadata where the spies-simulate-connection is stored.static final intOffset within the log metadata which the term length is stored.static final intOffset within the log metadata where the tether property is stored.static final intOffset within the log metadata where the type of the log buffer is stored.static final intOffset within the log metadata where the untethered linger timeout ns is stored.static final intOffset within the log metadata where the untethered resting timeout ns is stored.static final intOffset within the log metadata where the untethered window limit timeout ns is stored.static final intMaximum page size.static final intMinimum page size.static final intThe number of partitions the log is divided into.static final intMaximum buffer length for a log term.static final intMinimum buffer length for a log term.static final intOffset within the metadata where the tail values are stored. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intactiveTermCount(UnsafeBuffer metadataBuffer) Get the value of the active term count used by the producer of this log.static voidactiveTermCount(UnsafeBuffer metadataBuffer, int termCount) Set the value of the current active partition index for the producer.static voidactiveTermCountOrdered(UnsafeBuffer metadataBuffer, int termCount) Set the value of the current active term count for the producer using memory release semantics.static intactiveTransportCount(UnsafeBuffer metadataBuffer) Get the count of active transports for the Image.static voidactiveTransportCount(UnsafeBuffer metadataBuffer, int numberOfActiveTransports) Set the number of active transports for the Image.static voidapplyDefaultHeader(UnsafeBuffer metadataBuffer, UnsafeBuffer termBuffer, int termOffset) Apply the default header for a message in a term.static booleancasActiveTermCount(UnsafeBuffer metadataBuffer, int expectedTermCount, int updateTermCount) Compare and set the value of the current active term count.static booleancasRawTail(UnsafeBuffer metadataBuffer, int partitionIndex, long expectedRawTail, long updateRawTail) Compare and set the raw value of the tail for the given partition.static voidcheckPageSize(int pageSize) Check that page size is valid and alignment is valid.static voidcheckTermLength(int termLength) Check that term length is valid and alignment is valid.static intcomputeAssembledFrameLength(int length, int maxPayloadSize) Compute frame length for a message that has been reassembled from chunks ofmaxPayloadSize.static intcomputeFragmentedFrameLength(int length, int maxPayloadSize) Compute frame length for a message that is fragmented into chunks ofmaxPayloadSize.static longcomputeLogLength(int termLength, int filePageSize) Compute the total length of a log file given the term length.static longcomputePosition(int activeTermId, int termOffset, int positionBitsToShift, int initialTermId) Compute the current position in absolute number of bytes.static longcomputeTermBeginPosition(int activeTermId, int positionBitsToShift, int initialTermId) Compute the current position in absolute number of bytes for the beginning of a term.static intcomputeTermIdFromPosition(long position, int positionBitsToShift, int initialTermId) Compute the term id from a position.static longcorrelationId(UnsafeBuffer metadataBuffer) Get the value of the correlation ID for this log relating to the command which created it.static voidcorrelationId(UnsafeBuffer metadataBuffer, long id) Set the correlation ID used for this log relating to the command which created it.static UnsafeBufferdefaultFrameHeader(UnsafeBuffer metadataBuffer) Get a wrapper around the default frame header from the log metadata.static longendOfStreamPosition(UnsafeBuffer metadataBuffer) Get the value of the end of stream position.static voidendOfStreamPosition(UnsafeBuffer metadataBuffer, long position) Set the value of the end of stream position.static longentityTag(UnsafeBuffer metadataBuffer) Get the entity tag from the metadata.static voidentityTag(UnsafeBuffer metadataBuffer, long value) Set the entity tag in the metadata.static booleangroup(UnsafeBuffer metadataBuffer) Get whether the log is group from the metadata.static voidgroup(UnsafeBuffer metadataBuffer, boolean value) Set whether the log is group in the metadata.static intindexByPosition(long position, int positionBitsToShift) Determine the partition index given a stream position.static intindexByTerm(int initialTermId, int activeTermId) Determine the partition index to be used given the initial term and active term ids.static intindexByTermCount(long termCount) Determine the partition index based on number of terms that have passed.static voidinitialiseTailWithTermId(UnsafeBuffer metadataBuffer, int partitionIndex, int termId) Set the initial value for the termId in the upper bits of the tail counter.static intinitialTermId(UnsafeBuffer metadataBuffer) Get the value of the initial Term id used for this log.static voidinitialTermId(UnsafeBuffer metadataBuffer, int initialTermId) Set the initial term at which this log begins.static booleanisConnected(UnsafeBuffer metadataBuffer) Get whether the log is considered connected or not by the driver.static voidisConnected(UnsafeBuffer metadataBuffer, boolean isConnected) Set whether the log is considered connected or not by the driver.static booleanisPublicationRevoked(UnsafeBuffer metadataBuffer) Get whether the log's publication was revoked.static voidisPublicationRevoked(UnsafeBuffer metadataBuffer, boolean value) Set whether the log's publication was revoked.static booleanisResponse(UnsafeBuffer metadataBuffer) Get whether the log is response from the metadata.static voidisResponse(UnsafeBuffer metadataBuffer, boolean value) Set whether the log is response in the metadata.static longlingerTimeoutNs(UnsafeBuffer metadataBuffer) Get the linger timeout in nanoseconds from the metadata.static voidlingerTimeoutNs(UnsafeBuffer metadataBuffer, long value) Set the linger timeout in nanoseconds in the metadata.static intmaxResend(UnsafeBuffer metadataBuffer) Get the maximum resend count from the metadata.static voidmaxResend(UnsafeBuffer metadataBuffer, int value) Set the maximum resend count in the metadata.static intmtuLength(UnsafeBuffer metadataBuffer) Get the value of the MTU length used for this log.static voidmtuLength(UnsafeBuffer metadataBuffer, int mtuLength) Set the MTU length used for this log.static intnextPartitionIndex(int currentIndex) Rotate to the next partition in sequence for the term id.static intosDefaultSocketRcvbufLength(UnsafeBuffer metadataBuffer) Get the default length in bytes for the socket receive buffer as per OS configuration from the metadata.static voidosDefaultSocketRcvbufLength(UnsafeBuffer metadataBuffer, int value) Set the default length for the socket receive buffer as per OS configuration in the metadata.static intosDefaultSocketSndbufLength(UnsafeBuffer metadataBuffer) Get the default length in bytes for the socket send buffer as per OS configuration from the metadata.static voidosDefaultSocketSndbufLength(UnsafeBuffer metadataBuffer, int value) Set the default length for the socket send buffer as per OS configuration in the metadata.static intosMaxSocketRcvbufLength(UnsafeBuffer metadataBuffer) Get the maximum length in bytes for the socket receive buffer as per OS configuration from the metadata.static voidosMaxSocketRcvbufLength(UnsafeBuffer metadataBuffer, int value) Set the maximum allowed length in bytes for the socket receive buffer as per OS configuration in the metadata.static intosMaxSocketSndbufLength(UnsafeBuffer metadataBuffer) Get the maximum length in bytes for the socket send buffer as per OS configuration from the metadata.static voidosMaxSocketSndbufLength(UnsafeBuffer metadataBuffer, int value) Set the maximum allowed length in bytes for the socket send buffer as per OS configuration in the metadata.static longpackTail(int termId, int termOffset) Pack a termId and termOffset into a raw tail value.static intpageSize(UnsafeBuffer metadataBuffer) Get the value of the page size used for this log.static voidpageSize(UnsafeBuffer metadataBuffer, int pageSize) Set the page size used for this log.static intpositionBitsToShift(int termBufferLength) Get the number of bits to shift when dividing or multiplying by the term buffer length.static intpublicationWindowLength(UnsafeBuffer metadataBuffer) Get the publication window length from the metadata.static voidpublicationWindowLength(UnsafeBuffer metadataBuffer, int value) Set the publication window length in the metadata.static longrawTail(UnsafeBuffer metadataBuffer, int partitionIndex) Get the raw value of the tail for the given partition.static voidrawTail(UnsafeBuffer metadataBuffer, int partitionIndex, long rawTail) Set the raw value of the tail for the given partition.static longrawTailVolatile(UnsafeBuffer metadataBuffer) Get the raw value of the tail for the current active partition.static longrawTailVolatile(UnsafeBuffer metadataBuffer, int partitionIndex) Get the raw value of the tail for the given partition.static voidrawTailVolatile(UnsafeBuffer metadataBuffer, int partitionIndex, long rawTail) Set the raw value of the tail for the given partition.static intreceiverWindowLength(UnsafeBuffer metadataBuffer) Get the receiver window length from the metadata.static voidreceiverWindowLength(UnsafeBuffer metadataBuffer, int value) Set the receiver window length in the metadata.static booleanrejoin(UnsafeBuffer metadataBuffer) Get whether the log is rejoining from the metadata.static voidrejoin(UnsafeBuffer metadataBuffer, boolean value) Set whether the log is rejoining in the metadata.static booleanreliable(UnsafeBuffer metadataBuffer) Get whether the log is reliable from the metadata.static voidreliable(UnsafeBuffer metadataBuffer, boolean value) Set whether the log is reliable in the metadata.static longresponseCorrelationId(UnsafeBuffer metadataBuffer) Get the response correlation id from the metadata.static voidresponseCorrelationId(UnsafeBuffer metadataBuffer, long value) Set the response correlation id in the metadata.static booleanrotateLog(UnsafeBuffer metadataBuffer, int termCount, int termId) Rotate the log and update the tail counter for the new term.static booleansignalEos(UnsafeBuffer metadataBuffer) Get whether the signal EOS is enabled from the metadata.static voidsignalEos(UnsafeBuffer metadataBuffer, boolean value) Set whether the signal EOS is enabled in the metadata.static intsocketRcvbufLength(UnsafeBuffer metadataBuffer) Get the socket receive buffer length from the metadata.static voidsocketRcvbufLength(UnsafeBuffer metadataBuffer, int value) Set the socket receive buffer length in the metadata.static intsocketSndbufLength(UnsafeBuffer metadataBuffer) Get the socket send buffer length from the metadata.static voidsocketSndbufLength(UnsafeBuffer metadataBuffer, int value) Set the socket send buffer length in the metadata.static booleansparse(UnsafeBuffer metadataBuffer) Get whether the log is sparse from the metadata.static voidsparse(UnsafeBuffer metadataBuffer, boolean value) Set whether the log is sparse in the metadata.static booleanspiesSimulateConnection(UnsafeBuffer metadataBuffer) Get whether spies simulate connection from the metadata.static voidspiesSimulateConnection(UnsafeBuffer metadataBuffer, boolean value) Set whether spies simulate connection in the metadata.static voidstoreDefaultFrameHeader(UnsafeBuffer metadataBuffer, DirectBuffer defaultHeader) Store the default frame header to the log metadata buffer.static inttermId(long rawTail) Get the termId from a packed raw tail value.static inttermLength(UnsafeBuffer metadataBuffer) Get the value of the Term Length used for this log.static voidtermLength(UnsafeBuffer metadataBuffer, int termLength) Set the term length used for this log.static inttermOffset(long result) The termOffset as a result of the append operation.static inttermOffset(long rawTail, long termLength) Read the termOffset from a packed raw tail value.static booleantether(UnsafeBuffer metadataBuffer) Get whether the log is tethered from the metadata.static voidtether(UnsafeBuffer metadataBuffer, boolean value) Set whether the log is tethered in the metadata.static bytetype(UnsafeBuffer metadataBuffer) Get type information from this log buffer.static voidtype(UnsafeBuffer metadataBuffer, byte value) Settypeinformation for this log buffer.static longuntetheredLingerTimeoutNs(UnsafeBuffer metadataBuffer) Get the untethered linger timeout in nanoseconds from the metadata.static voiduntetheredLingerTimeoutNs(UnsafeBuffer metadataBuffer, long value) Set the untethered linger timeout in nanoseconds in the metadata.static longuntetheredRestingTimeoutNs(UnsafeBuffer metadataBuffer) Get the untethered resting timeout in nanoseconds from the metadata.static voiduntetheredRestingTimeoutNs(UnsafeBuffer metadataBuffer, long value) Set the untethered resting timeout in nanoseconds in the metadata.static longuntetheredWindowLimitTimeoutNs(UnsafeBuffer metadataBuffer) Get the untethered window limit timeout in nanoseconds from the metadata.static voiduntetheredWindowLimitTimeoutNs(UnsafeBuffer metadataBuffer, long value) Set the untethered window limit timeout in nanoseconds in the metadata.
-
Field Details
-
PARTITION_COUNT
public static final int PARTITION_COUNTThe number of partitions the log is divided into.- See Also:
-
LOG_META_DATA_SECTION_INDEX
public static final int LOG_META_DATA_SECTION_INDEXSection index for which buffer contains the log metadata.- See Also:
-
TERM_MIN_LENGTH
public static final int TERM_MIN_LENGTHMinimum buffer length for a log term.- See Also:
-
TERM_MAX_LENGTH
public static final int TERM_MAX_LENGTHMaximum buffer length for a log term.- See Also:
-
PAGE_MIN_SIZE
public static final int PAGE_MIN_SIZEMinimum page size.- See Also:
-
PAGE_MAX_SIZE
public static final int PAGE_MAX_SIZEMaximum page size.- See Also:
-
LOG_BUFFER_TYPE_CONCURRENT_PUBLICATION
public static final byte LOG_BUFFER_TYPE_CONCURRENT_PUBLICATIONValue for thetypefield to indicate a concurrent publication.- See Also:
-
LOG_BUFFER_TYPE_EXCLUSIVE_PUBLICATION
public static final byte LOG_BUFFER_TYPE_EXCLUSIVE_PUBLICATIONValue for thetypefield to indicate an exclusive publication.- See Also:
-
LOG_BUFFER_TYPE_PUBLICATION_IMAGE
public static final byte LOG_BUFFER_TYPE_PUBLICATION_IMAGEValue for thetypefield to indicate a subscription.- See Also:
-
TERM_TAIL_COUNTERS_OFFSET
public static final int TERM_TAIL_COUNTERS_OFFSETOffset within the metadata where the tail values are stored. -
LOG_ACTIVE_TERM_COUNT_OFFSET
public static final int LOG_ACTIVE_TERM_COUNT_OFFSETOffset within the log metadata where the active partition index is stored. -
LOG_END_OF_STREAM_POSITION_OFFSET
public static final int LOG_END_OF_STREAM_POSITION_OFFSETOffset within the log metadata where the position of the End of Stream is stored. -
LOG_IS_CONNECTED_OFFSET
public static final int LOG_IS_CONNECTED_OFFSETOffset within the log metadata where whether the log is connected or not is stored. -
LOG_ACTIVE_TRANSPORT_COUNT
public static final int LOG_ACTIVE_TRANSPORT_COUNTOffset within the log metadata where the count of active transports is stored. -
LOG_INITIAL_TERM_ID_OFFSET
public static final int LOG_INITIAL_TERM_ID_OFFSETOffset within the log metadata where the active term id is stored. -
LOG_DEFAULT_FRAME_HEADER_LENGTH_OFFSET
public static final int LOG_DEFAULT_FRAME_HEADER_LENGTH_OFFSETOffset within the log metadata which the length field for the frame header is stored. -
LOG_MTU_LENGTH_OFFSET
public static final int LOG_MTU_LENGTH_OFFSETOffset within the log metadata which the MTU length is stored. -
LOG_CORRELATION_ID_OFFSET
public static final int LOG_CORRELATION_ID_OFFSETOffset within the log metadata which the correlation id is stored. -
LOG_TERM_LENGTH_OFFSET
public static final int LOG_TERM_LENGTH_OFFSETOffset within the log metadata which the term length is stored. -
LOG_PAGE_SIZE_OFFSET
public static final int LOG_PAGE_SIZE_OFFSETOffset within the log metadata which the page size is stored. -
LOG_DEFAULT_FRAME_HEADER_OFFSET
public static final int LOG_DEFAULT_FRAME_HEADER_OFFSETOffset at which the default frame headers begin. -
LOG_DEFAULT_FRAME_HEADER_MAX_LENGTH
public static final int LOG_DEFAULT_FRAME_HEADER_MAX_LENGTHMaximum length of a frame header.- See Also:
-
LOG_SPARSE_OFFSET
public static final int LOG_SPARSE_OFFSETOffset within the log metadata where the sparse property is stored. -
LOG_TETHER_OFFSET
public static final int LOG_TETHER_OFFSETOffset within the log metadata where the tether property is stored. -
LOG_IS_PUBLICATION_REVOKED_OFFSET
public static final int LOG_IS_PUBLICATION_REVOKED_OFFSETOffset within the log metadata where the 'publication revoked' status is indicated. -
LOG_TYPE_OFFSET
public static final int LOG_TYPE_OFFSETOffset within the log metadata where the type of the log buffer is stored. -
LOG_REJOIN_OFFSET
public static final int LOG_REJOIN_OFFSETOffset within the log metadata where the rejoin property is stored. -
LOG_RELIABLE_OFFSET
public static final int LOG_RELIABLE_OFFSETOffset within the log metadata where the reliable property is stored. -
LOG_SOCKET_RCVBUF_LENGTH_OFFSET
public static final int LOG_SOCKET_RCVBUF_LENGTH_OFFSETOffset within the log metadata where the socket receive buffer length is stored. -
LOG_OS_DEFAULT_SOCKET_RCVBUF_LENGTH_OFFSET
public static final int LOG_OS_DEFAULT_SOCKET_RCVBUF_LENGTH_OFFSETOffset within the log metadata where the OS default length for the socket receive buffer is stored. -
LOG_OS_MAX_SOCKET_RCVBUF_LENGTH_OFFSET
public static final int LOG_OS_MAX_SOCKET_RCVBUF_LENGTH_OFFSETOffset within the log metadata where the OS maximum length for the socket receive buffer is stored. -
LOG_SOCKET_SNDBUF_LENGTH_OFFSET
public static final int LOG_SOCKET_SNDBUF_LENGTH_OFFSETOffset within the log metadata where the socket send buffer length is stored. -
LOG_OS_DEFAULT_SOCKET_SNDBUF_LENGTH_OFFSET
public static final int LOG_OS_DEFAULT_SOCKET_SNDBUF_LENGTH_OFFSETOffset within the log metadata where the OS default length for the socket send buffer is stored. -
LOG_OS_MAX_SOCKET_SNDBUF_LENGTH_OFFSET
public static final int LOG_OS_MAX_SOCKET_SNDBUF_LENGTH_OFFSETOffset within the log metadata where the OS maximum length for the socket send buffer is stored. -
LOG_RECEIVER_WINDOW_LENGTH_OFFSET
public static final int LOG_RECEIVER_WINDOW_LENGTH_OFFSETOffset within the log metadata where the receiver window length is stored. -
LOG_PUBLICATION_WINDOW_LENGTH_OFFSET
public static final int LOG_PUBLICATION_WINDOW_LENGTH_OFFSETOffset within the log metadata where the publication window length is stored. -
LOG_UNTETHERED_WINDOW_LIMIT_TIMEOUT_NS_OFFSET
public static final int LOG_UNTETHERED_WINDOW_LIMIT_TIMEOUT_NS_OFFSETOffset within the log metadata where the untethered window limit timeout ns is stored. -
LOG_UNTETHERED_LINGER_TIMEOUT_NS_OFFSET
public static final int LOG_UNTETHERED_LINGER_TIMEOUT_NS_OFFSETOffset within the log metadata where the untethered linger timeout ns is stored. -
LOG_UNTETHERED_RESTING_TIMEOUT_NS_OFFSET
public static final int LOG_UNTETHERED_RESTING_TIMEOUT_NS_OFFSETOffset within the log metadata where the untethered resting timeout ns is stored. -
LOG_MAX_RESEND_OFFSET
public static final int LOG_MAX_RESEND_OFFSETOffset within the log metadata where the max resend is stored. -
LOG_LINGER_TIMEOUT_NS_OFFSET
public static final int LOG_LINGER_TIMEOUT_NS_OFFSETOffset within the log metadata where the linger timeout ns is stored. -
LOG_SIGNAL_EOS_OFFSET
public static final int LOG_SIGNAL_EOS_OFFSETOffset within the log metadata where the signal-eos is stored. -
LOG_SPIES_SIMULATE_CONNECTION_OFFSET
public static final int LOG_SPIES_SIMULATE_CONNECTION_OFFSETOffset within the log metadata where the spies-simulate-connection is stored. -
LOG_GROUP_OFFSET
public static final int LOG_GROUP_OFFSETOffset within the log metadata where the group is stored. -
LOG_ENTITY_TAG_OFFSET
public static final int LOG_ENTITY_TAG_OFFSETOffset within the log metadata where the entity tag is stored. -
LOG_RESPONSE_CORRELATION_ID_OFFSET
public static final int LOG_RESPONSE_CORRELATION_ID_OFFSETOffset within the log metadata where the response correlation id is stored. -
LOG_IS_RESPONSE_OFFSET
public static final int LOG_IS_RESPONSE_OFFSETOffset within the log metadata where is-response is stored. -
LOG_META_DATA_LENGTH
public static final int LOG_META_DATA_LENGTHTotal length of the log metadata buffer in bytes.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 Term Count | +---------------------------------------------------------------+ | Cache Line Padding ... ... | +---------------------------------------------------------------+ | End of Stream Position | | | +---------------------------------------------------------------+ | Is Connected | +---------------------------------------------------------------+ | Active Transport Count | +---------------------------------------------------------------+ | Cache Line Padding ... ... | +---------------------------------------------------------------+ | Registration / Correlation ID | | | +---------------------------------------------------------------+ | Initial Term Id | +---------------------------------------------------------------+ | Default Frame Header Length | +---------------------------------------------------------------+ | MTU Length | +---------------------------------------------------------------+ | Term Length | +---------------------------------------------------------------+ | Page Size | +---------------------------------------------------------------+ | Publication Window Length | +---------------------------------------------------------------+ | Receiver Window Length | +---------------------------------------------------------------+ | Socket Send Buffer Length | +---------------------------------------------------------------+ | OS Default Socket Send Buffer Length | +---------------------------------------------------------------+ | OS Max Socket Send Buffer Length | +---------------------------------------------------------------+ | Socket Receive Buffer Length | +---------------------------------------------------------------+ | OS Default Socket Receive Buffer Length | +---------------------------------------------------------------+ | OS Max Socket Receive Buffer Length | +---------------------------------------------------------------+ | Maximum Resend | +---------------------------------------------------------------+ | Entity tag | | | +---------------------------------------------------------------+ | Response correlation id | | | +---------------------------------------------------------------+ | Default Frame Header ... ... | +---------------------------------------------------------------+ | Linger Timeout (ns) | | | +---------------------------------------------------------------+ | Untethered Window Limit Timeout (ns) | | | +---------------------------------------------------------------+ | Untethered Resting Timeout (ns) | | | +---------------------------------------------------------------+ | Group | +---------------------------------------------------------------+ | Is response | +---------------------------------------------------------------+ | Rejoin | +---------------------------------------------------------------+ | Reliable | +---------------------------------------------------------------+ | Sparse | +---------------------------------------------------------------+ | Signal EOS | +---------------------------------------------------------------+ | Spies Simulate Connection | +---------------------------------------------------------------+ | Tether | +---------------------------------------------------------------+ | Is publication revoked | +---------------------------------------------------------------+ | Alignment gap | +---------------------------------------------------------------+ | Untethered Linger Timeout (ns) | | | +---------------------------------------------------------------+
-
-
Constructor Details
-
LogBufferDescriptor
public LogBufferDescriptor()
-
-
Method Details
-
checkTermLength
public static void checkTermLength(int termLength) Check that term length is valid and alignment is valid.- Parameters:
termLength- to be checked.- Throws:
IllegalStateException- if the length is not as expected.
-
checkPageSize
public static void checkPageSize(int pageSize) Check that page size is valid and alignment is valid.- Parameters:
pageSize- to be checked.- Throws:
IllegalStateException- if the size is not as expected.
-
initialTermId
Get the value of the initial Term id used for this log.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the value of the initial Term id used for this log.
-
initialTermId
Set the initial term at which this log begins. Initial should be randomised so that stream does not get reused accidentally.- Parameters:
metadataBuffer- containing the meta data.initialTermId- value to be set.
-
mtuLength
Get the value of the MTU length used for this log.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the value of the MTU length used for this log.
-
mtuLength
Set the MTU length used for this log.- Parameters:
metadataBuffer- containing the meta data.mtuLength- value to be set.
-
termLength
Get the value of the Term Length used for this log.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the value of the term length used for this log.
-
termLength
Set the term length used for this log.- Parameters:
metadataBuffer- containing the meta data.termLength- value to be set.
-
pageSize
Get the value of the page size used for this log.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the value of the page size used for this log.
-
pageSize
Set the page size used for this log.- Parameters:
metadataBuffer- containing the meta data.pageSize- value to be set.
-
correlationId
Get the value of the correlation ID for this log relating to the command which created it.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the value of the correlation ID used for this log.
-
correlationId
Set the correlation ID used for this log relating to the command which created it.- Parameters:
metadataBuffer- containing the meta data.id- value to be set.
-
isConnected
Get whether the log is considered connected or not by the driver.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- whether the log is considered connected or not by the driver.
-
isConnected
Set whether the log is considered connected or not by the driver.- Parameters:
metadataBuffer- containing the meta data.isConnected- or not.
-
activeTransportCount
Get the count of active transports for the Image.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- count of active transports.
-
activeTransportCount
Set the number of active transports for the Image.- Parameters:
metadataBuffer- containing the meta data.numberOfActiveTransports- value to be set.
-
endOfStreamPosition
Get the value of the end of stream position.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the value of end of stream position
-
endOfStreamPosition
Set the value of the end of stream position.- Parameters:
metadataBuffer- containing the meta data.position- value of the end of stream position.
-
activeTermCount
Get the value of the active term count used by the producer of this log. Consumers may have a different active term count if they are running behind. The read is done with volatile semantics.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the value of the active term count used by the producer of this log.
-
activeTermCountOrdered
Set the value of the current active term count for the producer using memory release semantics.- Parameters:
metadataBuffer- containing the meta data.termCount- value of the active term count used by the producer of this log.
-
casActiveTermCount
public static boolean casActiveTermCount(UnsafeBuffer metadataBuffer, int expectedTermCount, int updateTermCount) Compare and set the value of the current active term count.- Parameters:
metadataBuffer- containing the meta data.expectedTermCount- value of the active term count expected in the log.updateTermCount- value of the active term count to be updated in the log.- Returns:
- true if successful otherwise false.
-
activeTermCount
Set the value of the current active partition index for the producer.- Parameters:
metadataBuffer- containing the meta data.termCount- value of the active term count used by the producer of this log.
-
nextPartitionIndex
public static int nextPartitionIndex(int currentIndex) Rotate to the next partition in sequence for the term id.- Parameters:
currentIndex- partition index.- Returns:
- the next partition index.
-
indexByTerm
public static int indexByTerm(int initialTermId, int activeTermId) Determine the partition index to be used given the initial term and active term ids.- Parameters:
initialTermId- at which the log buffer usage began.activeTermId- that is in current usage.- Returns:
- the index of which buffer should be used.
-
indexByTermCount
public static int indexByTermCount(long termCount) Determine the partition index based on number of terms that have passed.- Parameters:
termCount- for the number of terms that have passed.- Returns:
- the partition index for the term count.
-
indexByPosition
public static int indexByPosition(long position, int positionBitsToShift) Determine the partition index given a stream position.- Parameters:
position- in the stream in bytes.positionBitsToShift- number of times to left shift the term count to multiply by term length.- Returns:
- the partition index for the position.
-
computePosition
public static long computePosition(int activeTermId, int termOffset, int positionBitsToShift, int initialTermId) Compute the current position in absolute number of bytes.- Parameters:
activeTermId- active term id.termOffset- in the term.positionBitsToShift- number of times to left shift the term count to multiply by term length.initialTermId- the initial term id that this stream started on.- Returns:
- the absolute position in bytes.
-
computeTermBeginPosition
public static long computeTermBeginPosition(int activeTermId, int positionBitsToShift, int initialTermId) Compute the current position in absolute number of bytes for the beginning of a term.- Parameters:
activeTermId- active term id.positionBitsToShift- number of times to left shift the term count to multiply by term length.initialTermId- the initial term id that this stream started on.- Returns:
- the absolute position in bytes.
-
computeTermIdFromPosition
public static int computeTermIdFromPosition(long position, int positionBitsToShift, int initialTermId) Compute the term id from a position.- Parameters:
position- to calculate frompositionBitsToShift- number of times to left shift the term count to multiply by term length.initialTermId- the initial term id that this stream started on.- Returns:
- the term id according to the position.
-
computeLogLength
public static long computeLogLength(int termLength, int filePageSize) Compute the total length of a log file given the term length.Assumes
TERM_MAX_LENGTHis 1 GB and that filePageSize is 1 GB or less and a power of 2.- Parameters:
termLength- on which to base the calculation.filePageSize- to use for log.- Returns:
- the total length of the log file.
-
storeDefaultFrameHeader
Store the default frame header to the log metadata buffer.- Parameters:
metadataBuffer- into which the default headers should be stored.defaultHeader- to be stored.- Throws:
IllegalArgumentException- if the defaultHeader larger thanLOG_DEFAULT_FRAME_HEADER_MAX_LENGTH.
-
defaultFrameHeader
Get a wrapper around the default frame header from the log metadata.- Parameters:
metadataBuffer- containing the raw bytes for the default frame header.- Returns:
- a buffer wrapping the raw bytes.
-
applyDefaultHeader
public static void applyDefaultHeader(UnsafeBuffer metadataBuffer, UnsafeBuffer termBuffer, int termOffset) Apply the default header for a message in a term.- Parameters:
metadataBuffer- containing the default headers.termBuffer- to which the default header should be applied.termOffset- at which the default should be applied.
-
rotateLog
Rotate the log and update the tail counter for the new term.This method is safe for concurrent use.
- Parameters:
metadataBuffer- for the log.termCount- from which to rotate.termId- to be used in the default headers.- Returns:
- true if log was rotated.
-
initialiseTailWithTermId
public static void initialiseTailWithTermId(UnsafeBuffer metadataBuffer, int partitionIndex, int termId) Set the initial value for the termId in the upper bits of the tail counter.- Parameters:
metadataBuffer- contain the tail counter.partitionIndex- to be initialised.termId- to be set.
-
termId
public static int termId(long rawTail) Get the termId from a packed raw tail value.- Parameters:
rawTail- containing the termId.- Returns:
- the termId from a packed raw tail value.
-
termOffset
public static int termOffset(long rawTail, long termLength) Read the termOffset from a packed raw tail value.- Parameters:
rawTail- containing the termOffset.termLength- that the offset cannot exceed.- Returns:
- the termOffset value.
-
termOffset
public static int termOffset(long result) The termOffset as a result of the append operation.- Parameters:
result- into which the termOffset value has been packed.- Returns:
- the termOffset after the append operation.
-
packTail
public static long packTail(int termId, int termOffset) Pack a termId and termOffset into a raw tail value.- Parameters:
termId- to be packed.termOffset- to be packed.- Returns:
- the packed value.
-
rawTail
Set the raw value of the tail for the given partition.- Parameters:
metadataBuffer- containing the tail counters.partitionIndex- for the tail counter.rawTail- to be stored.
-
rawTail
Get the raw value of the tail for the given partition.- Parameters:
metadataBuffer- containing the tail counters.partitionIndex- for the tail counter.- Returns:
- the raw value of the tail for the current active partition.
-
rawTailVolatile
Set the raw value of the tail for the given partition.- Parameters:
metadataBuffer- containing the tail counters.partitionIndex- for the tail counter.rawTail- to be stored.
-
rawTailVolatile
Get the raw value of the tail for the given partition.- Parameters:
metadataBuffer- containing the tail counters.partitionIndex- for the tail counter.- Returns:
- the raw value of the tail for the current active partition.
-
rawTailVolatile
Get the raw value of the tail for the current active partition.- Parameters:
metadataBuffer- containing the tail counters.- Returns:
- the raw value of the tail for the current active partition.
-
casRawTail
public static boolean casRawTail(UnsafeBuffer metadataBuffer, int partitionIndex, long expectedRawTail, long updateRawTail) Compare and set the raw value of the tail for the given partition.- Parameters:
metadataBuffer- containing the tail counters.partitionIndex- for the tail counter.expectedRawTail- expected current value.updateRawTail- to be applied.- Returns:
- true if the update was successful otherwise false.
-
positionBitsToShift
public static int positionBitsToShift(int termBufferLength) Get the number of bits to shift when dividing or multiplying by the term buffer length.- Parameters:
termBufferLength- to compute the number of bits to shift for.- Returns:
- the number of bits to shift to divide or multiply by the term buffer length.
-
computeFragmentedFrameLength
public static int computeFragmentedFrameLength(int length, int maxPayloadSize) Compute frame length for a message that is fragmented into chunks ofmaxPayloadSize.- Parameters:
length- of the message.maxPayloadSize- fragment size without the header.- Returns:
- message length after fragmentation.
-
computeAssembledFrameLength
public static int computeAssembledFrameLength(int length, int maxPayloadSize) Compute frame length for a message that has been reassembled from chunks ofmaxPayloadSize.- Parameters:
length- of the message.maxPayloadSize- fragment size without the header.- Returns:
- message length after fragmentation.
-
sparse
Get whether the log is sparse from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- true if the log is sparse, otherwise false.
-
sparse
Set whether the log is sparse in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- true if the log is sparse, otherwise false.
-
tether
Get whether the log is tethered from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- true if the log is tethered, otherwise false.
-
tether
Set whether the log is tethered in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- true if the log is tethered, otherwise false.
-
isPublicationRevoked
Get whether the log's publication was revoked.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- true if the log's publication was revoked, otherwise false.
-
isPublicationRevoked
Set whether the log's publication was revoked.- Parameters:
metadataBuffer- containing the meta data.value- true if the log's publication was revoked, otherwise false.
-
type
Get type information from this log buffer.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- one of the
LOG_BUFFER_TYPE_CONCURRENT_PUBLICATION,LOG_BUFFER_TYPE_EXCLUSIVE_PUBLICATIONorLOG_BUFFER_TYPE_PUBLICATION_IMAGE
-
type
Settypeinformation for this log buffer.- Parameters:
metadataBuffer- containing the meta data.value- one of theLOG_BUFFER_TYPE_CONCURRENT_PUBLICATION,LOG_BUFFER_TYPE_EXCLUSIVE_PUBLICATIONorLOG_BUFFER_TYPE_PUBLICATION_IMAGE.
-
group
Get whether the log is group from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- true if the log is group, otherwise false.
-
group
Set whether the log is group in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- true if the log is group, otherwise false.
-
isResponse
Get whether the log is response from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- true if the log is group, otherwise false.
-
isResponse
Set whether the log is response in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- true if the log is group, otherwise false.
-
rejoin
Get whether the log is rejoining from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- true if the log is rejoining, otherwise false.
-
rejoin
Set whether the log is rejoining in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- true if the log is rejoining, otherwise false.
-
reliable
Get whether the log is reliable from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- true if the log is reliable, otherwise false.
-
reliable
Set whether the log is reliable in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- true if the log is reliable, otherwise false.
-
socketRcvbufLength
Get the socket receive buffer length from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the socket receive buffer length.
-
socketRcvbufLength
Set the socket receive buffer length in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the socket receive buffer length to set.
-
osDefaultSocketRcvbufLength
Get the default length in bytes for the socket receive buffer as per OS configuration from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the default length in bytes for the socket receive buffer.
-
osDefaultSocketRcvbufLength
Set the default length for the socket receive buffer as per OS configuration in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the default length in bytes for the socket receive buffer.
-
osMaxSocketRcvbufLength
Get the maximum length in bytes for the socket receive buffer as per OS configuration from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the maximum allowed length in bytes for the socket receive buffer.
-
osMaxSocketRcvbufLength
Set the maximum allowed length in bytes for the socket receive buffer as per OS configuration in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the maximum allowed length in bytes for the socket receive buffer.
-
socketSndbufLength
Get the socket send buffer length from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the socket send buffer length.
-
socketSndbufLength
Set the socket send buffer length in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the socket send buffer length to set.
-
osDefaultSocketSndbufLength
Get the default length in bytes for the socket send buffer as per OS configuration from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the default length in bytes for the socket send buffer.
-
osDefaultSocketSndbufLength
Set the default length for the socket send buffer as per OS configuration in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the default length in bytes for the socket send buffer.
-
osMaxSocketSndbufLength
Get the maximum length in bytes for the socket send buffer as per OS configuration from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the maximum allowed length in bytes for the socket send buffer.
-
osMaxSocketSndbufLength
Set the maximum allowed length in bytes for the socket send buffer as per OS configuration in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the maximum allowed length in bytes for the socket send buffer.
-
receiverWindowLength
Get the receiver window length from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the receiver window length.
-
receiverWindowLength
Set the receiver window length in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the receiver window length to set.
-
publicationWindowLength
Get the publication window length from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the publication window length.
-
publicationWindowLength
Set the publication window length in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the publication window length to set.
-
untetheredWindowLimitTimeoutNs
Get the untethered window limit timeout in nanoseconds from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the untethered window limit timeout in nanoseconds.
-
untetheredWindowLimitTimeoutNs
Set the untethered window limit timeout in nanoseconds in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the untethered window limit timeout to set.
-
untetheredLingerTimeoutNs
Get the untethered linger timeout in nanoseconds from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the untethered window limit timeout in nanoseconds.
-
untetheredLingerTimeoutNs
Set the untethered linger timeout in nanoseconds in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the untethered linger timeout to set.
-
untetheredRestingTimeoutNs
Get the untethered resting timeout in nanoseconds from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the untethered resting timeout in nanoseconds.
-
untetheredRestingTimeoutNs
Set the untethered resting timeout in nanoseconds in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the untethered resting timeout to set.
-
maxResend
Get the maximum resend count from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the maximum resend count.
-
maxResend
Set the maximum resend count in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the maximum resend count to set.
-
lingerTimeoutNs
Get the linger timeout in nanoseconds from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the linger timeout in nanoseconds.
-
lingerTimeoutNs
Set the linger timeout in nanoseconds in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the linger timeout to set.
-
entityTag
Get the entity tag from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the entity tag in nanoseconds.
-
entityTag
Set the entity tag in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the entity tag to set.
-
responseCorrelationId
Get the response correlation id from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- the entity tag in nanoseconds.
-
responseCorrelationId
Set the response correlation id in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- the response correlation id to set.
-
signalEos
Get whether the signal EOS is enabled from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- true if signal EOS is enabled, otherwise false.
-
signalEos
Set whether the signal EOS is enabled in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- true if signal EOS is enabled, otherwise false.
-
spiesSimulateConnection
Get whether spies simulate connection from the metadata.- Parameters:
metadataBuffer- containing the meta data.- Returns:
- true if spies simulate connection, otherwise false.
-
spiesSimulateConnection
Set whether spies simulate connection in the metadata.- Parameters:
metadataBuffer- containing the meta data.value- true if spies simulate connection, otherwise false.
-