Class LogBufferDescriptor

java.lang.Object
io.aeron.logbuffer.LogBufferDescriptor

public class LogBufferDescriptor extends Object
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 Details

    • PARTITION_COUNT

      public static final int PARTITION_COUNT
      The number of partitions the log is divided into.
      See Also:
    • LOG_META_DATA_SECTION_INDEX

      public static final int LOG_META_DATA_SECTION_INDEX
      Section index for which buffer contains the log metadata.
      See Also:
    • TERM_MIN_LENGTH

      public static final int TERM_MIN_LENGTH
      Minimum buffer length for a log term.
      See Also:
    • TERM_MAX_LENGTH

      public static final int TERM_MAX_LENGTH
      Maximum buffer length for a log term.
      See Also:
    • PAGE_MIN_SIZE

      public static final int PAGE_MIN_SIZE
      Minimum page size.
      See Also:
    • PAGE_MAX_SIZE

      public static final int PAGE_MAX_SIZE
      Maximum page size.
      See Also:
    • LOG_BUFFER_TYPE_CONCURRENT_PUBLICATION

      public static final byte LOG_BUFFER_TYPE_CONCURRENT_PUBLICATION
      Value for the type field to indicate a concurrent publication.
      See Also:
    • LOG_BUFFER_TYPE_EXCLUSIVE_PUBLICATION

      public static final byte LOG_BUFFER_TYPE_EXCLUSIVE_PUBLICATION
      Value for the type field to indicate an exclusive publication.
      See Also:
    • LOG_BUFFER_TYPE_PUBLICATION_IMAGE

      public static final byte LOG_BUFFER_TYPE_PUBLICATION_IMAGE
      Value for the type field to indicate a subscription.
      See Also:
    • TERM_TAIL_COUNTERS_OFFSET

      public static final int TERM_TAIL_COUNTERS_OFFSET
      Offset within the metadata where the tail values are stored.
    • LOG_ACTIVE_TERM_COUNT_OFFSET

      public static final int LOG_ACTIVE_TERM_COUNT_OFFSET
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset 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_COUNT
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset within the log metadata which the MTU length is stored.
    • LOG_CORRELATION_ID_OFFSET

      public static final int LOG_CORRELATION_ID_OFFSET
      Offset within the log metadata which the correlation id is stored.
    • LOG_TERM_LENGTH_OFFSET

      public static final int LOG_TERM_LENGTH_OFFSET
      Offset within the log metadata which the term length is stored.
    • LOG_PAGE_SIZE_OFFSET

      public static final int LOG_PAGE_SIZE_OFFSET
      Offset within the log metadata which the page size is stored.
    • LOG_DEFAULT_FRAME_HEADER_OFFSET

      public static final int LOG_DEFAULT_FRAME_HEADER_OFFSET
      Offset at which the default frame headers begin.
    • LOG_DEFAULT_FRAME_HEADER_MAX_LENGTH

      public static final int LOG_DEFAULT_FRAME_HEADER_MAX_LENGTH
      Maximum length of a frame header.
      See Also:
    • LOG_SPARSE_OFFSET

      public static final int LOG_SPARSE_OFFSET
      Offset within the log metadata where the sparse property is stored.
    • LOG_TETHER_OFFSET

      public static final int LOG_TETHER_OFFSET
      Offset within the log metadata where the tether property is stored.
    • LOG_IS_PUBLICATION_REVOKED_OFFSET

      public static final int LOG_IS_PUBLICATION_REVOKED_OFFSET
      Offset within the log metadata where the 'publication revoked' status is indicated.
    • LOG_TYPE_OFFSET

      public static final int LOG_TYPE_OFFSET
      Offset within the log metadata where the type of the log buffer is stored.
      See Also:
    • LOG_REJOIN_OFFSET

      public static final int LOG_REJOIN_OFFSET
      Offset within the log metadata where the rejoin property is stored.
    • LOG_RELIABLE_OFFSET

      public static final int LOG_RELIABLE_OFFSET
      Offset within the log metadata where the reliable property is stored.
    • LOG_SOCKET_RCVBUF_LENGTH_OFFSET

      public static final int LOG_SOCKET_RCVBUF_LENGTH_OFFSET
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset within the log metadata where the receiver window length is stored.
    • LOG_PUBLICATION_WINDOW_LENGTH_OFFSET

      public static final int LOG_PUBLICATION_WINDOW_LENGTH_OFFSET
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset 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_OFFSET
      Offset within the log metadata where the untethered resting timeout ns is stored.
    • LOG_MAX_RESEND_OFFSET

      public static final int LOG_MAX_RESEND_OFFSET
      Offset within the log metadata where the max resend is stored.
    • LOG_LINGER_TIMEOUT_NS_OFFSET

      public static final int LOG_LINGER_TIMEOUT_NS_OFFSET
      Offset within the log metadata where the linger timeout ns is stored.
    • LOG_SIGNAL_EOS_OFFSET

      public static final int LOG_SIGNAL_EOS_OFFSET
      Offset within the log metadata where the signal-eos is stored.
    • LOG_SPIES_SIMULATE_CONNECTION_OFFSET

      public static final int LOG_SPIES_SIMULATE_CONNECTION_OFFSET
      Offset within the log metadata where the spies-simulate-connection is stored.
    • LOG_GROUP_OFFSET

      public static final int LOG_GROUP_OFFSET
      Offset within the log metadata where the group is stored.
    • LOG_ENTITY_TAG_OFFSET

      public static final int LOG_ENTITY_TAG_OFFSET
      Offset within the log metadata where the entity tag is stored.
    • LOG_RESPONSE_CORRELATION_ID_OFFSET

      public static final int LOG_RESPONSE_CORRELATION_ID_OFFSET
      Offset within the log metadata where the response correlation id is stored.
    • LOG_IS_RESPONSE_OFFSET

      public static final int LOG_IS_RESPONSE_OFFSET
      Offset within the log metadata where is-response is stored.
    • LOG_META_DATA_LENGTH

      public static final int LOG_META_DATA_LENGTH
      Total 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

      public static int initialTermId(UnsafeBuffer metadataBuffer)
      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

      public static void initialTermId(UnsafeBuffer metadataBuffer, int 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

      public static int mtuLength(UnsafeBuffer metadataBuffer)
      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

      public static void mtuLength(UnsafeBuffer metadataBuffer, int mtuLength)
      Set the MTU length used for this log.
      Parameters:
      metadataBuffer - containing the meta data.
      mtuLength - value to be set.
    • termLength

      public static int termLength(UnsafeBuffer metadataBuffer)
      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

      public static void termLength(UnsafeBuffer metadataBuffer, int termLength)
      Set the term length used for this log.
      Parameters:
      metadataBuffer - containing the meta data.
      termLength - value to be set.
    • pageSize

      public static int pageSize(UnsafeBuffer metadataBuffer)
      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

      public static void pageSize(UnsafeBuffer metadataBuffer, int pageSize)
      Set the page size used for this log.
      Parameters:
      metadataBuffer - containing the meta data.
      pageSize - value to be set.
    • correlationId

      public static long correlationId(UnsafeBuffer metadataBuffer)
      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

      public static void correlationId(UnsafeBuffer metadataBuffer, long id)
      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

      public static boolean isConnected(UnsafeBuffer metadataBuffer)
      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

      public static void isConnected(UnsafeBuffer metadataBuffer, boolean isConnected)
      Set whether the log is considered connected or not by the driver.
      Parameters:
      metadataBuffer - containing the meta data.
      isConnected - or not.
    • activeTransportCount

      public static int activeTransportCount(UnsafeBuffer metadataBuffer)
      Get the count of active transports for the Image.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      count of active transports.
    • activeTransportCount

      public static void activeTransportCount(UnsafeBuffer metadataBuffer, int numberOfActiveTransports)
      Set the number of active transports for the Image.
      Parameters:
      metadataBuffer - containing the meta data.
      numberOfActiveTransports - value to be set.
    • endOfStreamPosition

      public static long endOfStreamPosition(UnsafeBuffer metadataBuffer)
      Get the value of the end of stream position.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the value of end of stream position
    • endOfStreamPosition

      public static void endOfStreamPosition(UnsafeBuffer metadataBuffer, long position)
      Set the value of the end of stream position.
      Parameters:
      metadataBuffer - containing the meta data.
      position - value of the end of stream position.
    • activeTermCount

      public static int activeTermCount(UnsafeBuffer metadataBuffer)
      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

      public static void activeTermCountOrdered(UnsafeBuffer metadataBuffer, int termCount)
      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

      public static void activeTermCount(UnsafeBuffer metadataBuffer, int termCount)
      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 from
      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 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_LENGTH is 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

      public static void storeDefaultFrameHeader(UnsafeBuffer metadataBuffer, DirectBuffer defaultHeader)
      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 than LOG_DEFAULT_FRAME_HEADER_MAX_LENGTH.
    • defaultFrameHeader

      public static UnsafeBuffer defaultFrameHeader(UnsafeBuffer metadataBuffer)
      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

      public static boolean rotateLog(UnsafeBuffer metadataBuffer, int termCount, int termId)
      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

      public static void rawTail(UnsafeBuffer metadataBuffer, int partitionIndex, long 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

      public static long rawTail(UnsafeBuffer metadataBuffer, int partitionIndex)
      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

      public static void rawTailVolatile(UnsafeBuffer metadataBuffer, int partitionIndex, long 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.
    • rawTailVolatile

      public static long rawTailVolatile(UnsafeBuffer metadataBuffer, int partitionIndex)
      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

      public static long rawTailVolatile(UnsafeBuffer metadataBuffer)
      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 of maxPayloadSize.
      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 of maxPayloadSize.
      Parameters:
      length - of the message.
      maxPayloadSize - fragment size without the header.
      Returns:
      message length after fragmentation.
    • sparse

      public static boolean sparse(UnsafeBuffer metadataBuffer)
      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

      public static void sparse(UnsafeBuffer metadataBuffer, boolean value)
      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

      public static boolean tether(UnsafeBuffer metadataBuffer)
      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

      public static void tether(UnsafeBuffer metadataBuffer, boolean value)
      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

      public static boolean isPublicationRevoked(UnsafeBuffer metadataBuffer)
      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

      public static void isPublicationRevoked(UnsafeBuffer metadataBuffer, boolean value)
      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

      public static byte type(UnsafeBuffer metadataBuffer)
      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_PUBLICATION or LOG_BUFFER_TYPE_PUBLICATION_IMAGE
    • type

      public static void type(UnsafeBuffer metadataBuffer, byte value)
      Set type information for this log buffer.
      Parameters:
      metadataBuffer - containing the meta data.
      value - one of the LOG_BUFFER_TYPE_CONCURRENT_PUBLICATION, LOG_BUFFER_TYPE_EXCLUSIVE_PUBLICATION or LOG_BUFFER_TYPE_PUBLICATION_IMAGE.
    • group

      public static boolean group(UnsafeBuffer metadataBuffer)
      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

      public static void group(UnsafeBuffer metadataBuffer, boolean value)
      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

      public static boolean isResponse(UnsafeBuffer metadataBuffer)
      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

      public static void isResponse(UnsafeBuffer metadataBuffer, boolean value)
      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

      public static boolean rejoin(UnsafeBuffer metadataBuffer)
      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

      public static void rejoin(UnsafeBuffer metadataBuffer, boolean value)
      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

      public static boolean reliable(UnsafeBuffer metadataBuffer)
      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

      public static void reliable(UnsafeBuffer metadataBuffer, boolean value)
      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

      public static int socketRcvbufLength(UnsafeBuffer metadataBuffer)
      Get the socket receive buffer length from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the socket receive buffer length.
    • socketRcvbufLength

      public static void socketRcvbufLength(UnsafeBuffer metadataBuffer, int value)
      Set the socket receive buffer length in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the socket receive buffer length to set.
    • osDefaultSocketRcvbufLength

      public static int osDefaultSocketRcvbufLength(UnsafeBuffer metadataBuffer)
      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

      public static void osDefaultSocketRcvbufLength(UnsafeBuffer metadataBuffer, int value)
      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

      public static int osMaxSocketRcvbufLength(UnsafeBuffer metadataBuffer)
      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

      public static void osMaxSocketRcvbufLength(UnsafeBuffer metadataBuffer, int value)
      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

      public static int socketSndbufLength(UnsafeBuffer metadataBuffer)
      Get the socket send buffer length from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the socket send buffer length.
    • socketSndbufLength

      public static void socketSndbufLength(UnsafeBuffer metadataBuffer, int value)
      Set the socket send buffer length in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the socket send buffer length to set.
    • osDefaultSocketSndbufLength

      public static int osDefaultSocketSndbufLength(UnsafeBuffer metadataBuffer)
      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

      public static void osDefaultSocketSndbufLength(UnsafeBuffer metadataBuffer, int value)
      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

      public static int osMaxSocketSndbufLength(UnsafeBuffer metadataBuffer)
      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

      public static void osMaxSocketSndbufLength(UnsafeBuffer metadataBuffer, int value)
      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

      public static int receiverWindowLength(UnsafeBuffer metadataBuffer)
      Get the receiver window length from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the receiver window length.
    • receiverWindowLength

      public static void receiverWindowLength(UnsafeBuffer metadataBuffer, int value)
      Set the receiver window length in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the receiver window length to set.
    • publicationWindowLength

      public static int publicationWindowLength(UnsafeBuffer metadataBuffer)
      Get the publication window length from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the publication window length.
    • publicationWindowLength

      public static void publicationWindowLength(UnsafeBuffer metadataBuffer, int value)
      Set the publication window length in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the publication window length to set.
    • untetheredWindowLimitTimeoutNs

      public static long untetheredWindowLimitTimeoutNs(UnsafeBuffer metadataBuffer)
      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

      public static void untetheredWindowLimitTimeoutNs(UnsafeBuffer metadataBuffer, long value)
      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

      public static long untetheredLingerTimeoutNs(UnsafeBuffer metadataBuffer)
      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

      public static void untetheredLingerTimeoutNs(UnsafeBuffer metadataBuffer, long value)
      Set the untethered linger timeout in nanoseconds in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the untethered linger timeout to set.
    • untetheredRestingTimeoutNs

      public static long untetheredRestingTimeoutNs(UnsafeBuffer metadataBuffer)
      Get the untethered resting timeout in nanoseconds from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the untethered resting timeout in nanoseconds.
    • untetheredRestingTimeoutNs

      public static void untetheredRestingTimeoutNs(UnsafeBuffer metadataBuffer, long value)
      Set the untethered resting timeout in nanoseconds in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the untethered resting timeout to set.
    • maxResend

      public static int maxResend(UnsafeBuffer metadataBuffer)
      Get the maximum resend count from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the maximum resend count.
    • maxResend

      public static void maxResend(UnsafeBuffer metadataBuffer, int value)
      Set the maximum resend count in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the maximum resend count to set.
    • lingerTimeoutNs

      public static long lingerTimeoutNs(UnsafeBuffer metadataBuffer)
      Get the linger timeout in nanoseconds from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the linger timeout in nanoseconds.
    • lingerTimeoutNs

      public static void lingerTimeoutNs(UnsafeBuffer metadataBuffer, long value)
      Set the linger timeout in nanoseconds in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the linger timeout to set.
    • entityTag

      public static long entityTag(UnsafeBuffer metadataBuffer)
      Get the entity tag from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the entity tag in nanoseconds.
    • entityTag

      public static void entityTag(UnsafeBuffer metadataBuffer, long value)
      Set the entity tag in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the entity tag to set.
    • responseCorrelationId

      public static long responseCorrelationId(UnsafeBuffer metadataBuffer)
      Get the response correlation id from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      the entity tag in nanoseconds.
    • responseCorrelationId

      public static void responseCorrelationId(UnsafeBuffer metadataBuffer, long value)
      Set the response correlation id in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - the response correlation id to set.
    • signalEos

      public static boolean signalEos(UnsafeBuffer metadataBuffer)
      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

      public static void signalEos(UnsafeBuffer metadataBuffer, boolean value)
      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

      public static boolean spiesSimulateConnection(UnsafeBuffer metadataBuffer)
      Get whether spies simulate connection from the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      Returns:
      true if spies simulate connection, otherwise false.
    • spiesSimulateConnection

      public static void spiesSimulateConnection(UnsafeBuffer metadataBuffer, boolean value)
      Set whether spies simulate connection in the metadata.
      Parameters:
      metadataBuffer - containing the meta data.
      value - true if spies simulate connection, otherwise false.