Class BufferClaim

java.lang.Object
io.aeron.logbuffer.BufferClaim

public final class BufferClaim extends Object
Represents a claimed range in a buffer to be used for recording a message without copy semantics for later commit.

The claimed space is in buffer() between offset() and offset() + length(). When the buffer is filled with message data, use commit() to make it available to subscribers.

If the claimed space is no longer required it can be aborted by calling abort().

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Abort a claim of the message space to the log buffer so that the log can progress by ignoring this claim.
    The referenced buffer to be used.
    void
    Commit the message to the log buffer so that is it available to subscribers.
    byte
    Get the value of the flags field.
    flags(byte flags)
    Set the value of the header flags field.
    int
    Get the value of the header type field.
    headerType(int type)
    Set the value of the header type field.
    int
    The length of the claimed range in the buffer.
    int
    The offset in the buffer at which the claimed range begins.
    putBytes(DirectBuffer srcBuffer, int srcIndex, int length)
    Put bytes into the claimed buffer space for a message.
    long
    Get the value stored in the reserve space at the end of a data frame header.
    reservedValue(long value)
    Write the provided value into the reserved space at the end of the data frame header.
    void
    wrap(AtomicBuffer buffer, int offset, int length)
    Wrap a region of an underlying log buffer so can can represent a claimed space for use by a publisher.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BufferClaim

      public BufferClaim()
  • Method Details

    • wrap

      public void wrap(AtomicBuffer buffer, int offset, int length)
      Wrap a region of an underlying log buffer so can can represent a claimed space for use by a publisher.
      Parameters:
      buffer - to be wrapped.
      offset - at which the claimed region begins including space for the header.
      length - length of the underlying claimed region including space for the header.
    • buffer

      public MutableDirectBuffer buffer()
      The referenced buffer to be used.
      Returns:
      the referenced buffer to be used.
    • offset

      public int offset()
      The offset in the buffer at which the claimed range begins.
      Returns:
      offset in the buffer at which the range begins.
    • length

      public int length()
      The length of the claimed range in the buffer.
      Returns:
      length of the range in the buffer.
    • headerType

      public int headerType()
      Get the value of the header type field. The lower 16 bits are valid.
      Returns:
      the value of the header type field.
      See Also:
    • flags

      public byte flags()
      Get the value of the flags field.
      Returns:
      the value of the header flags field.
      See Also:
    • flags

      public BufferClaim flags(byte flags)
      Set the value of the header flags field.
      Parameters:
      flags - value to be set in the header.
      Returns:
      this for a fluent API.
      See Also:
    • headerType

      public BufferClaim headerType(int type)
      Set the value of the header type field. The lower 16 bits are valid.
      Parameters:
      type - value to be set in the header.
      Returns:
      this for a fluent API.
      See Also:
    • reservedValue

      public long reservedValue()
      Get the value stored in the reserve space at the end of a data frame header.

      Note: The value is in ByteOrder.LITTLE_ENDIAN format.

      Returns:
      the value stored in the reserve space at the end of a data frame header.
      See Also:
    • reservedValue

      public BufferClaim reservedValue(long value)
      Write the provided value into the reserved space at the end of the data frame header.

      Note: The value will be written in ByteOrder.LITTLE_ENDIAN format.

      Parameters:
      value - to be stored in the reserve space at the end of a data frame header.
      Returns:
      this for fluent API semantics.
      See Also:
    • putBytes

      public BufferClaim putBytes(DirectBuffer srcBuffer, int srcIndex, int length)
      Put bytes into the claimed buffer space for a message. To write multiple parts then use buffer() and offset().
      Parameters:
      srcBuffer - to copy into the claimed space.
      srcIndex - in the source buffer from which to copy.
      length - of the source buffer to copy.
      Returns:
      this for a fluent API.
    • commit

      public void commit()
      Commit the message to the log buffer so that is it available to subscribers.
    • abort

      public void abort()
      Abort a claim of the message space to the log buffer so that the log can progress by ignoring this claim.