Class ClaimedFragmentBatch

java.lang.Object
io.camunda.zeebe.dispatcher.ClaimedFragmentBatch

public class ClaimedFragmentBatch extends Object
A claimed batch of fragments in the buffer. Use nextFragment(int, int) to add a new fragment to the batch. Write the fragment message using getBuffer() and getFragmentOffset() to get the buffer offset of this fragment. Complete the whole batch operation by calling either commit() or abort().

The claimed batch is reusable but not thread-safe.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Commit all fragments of the batch and mark them as failed.
    void
    Commit all fragments of the batch so that it can be read by subscriptions.
    org.agrona.MutableDirectBuffer
     
    int
     
    long
    nextFragment(int length, int streamId)
    Add a new fragment to the batch.
    void
    wrap(org.agrona.concurrent.UnsafeBuffer underlyingBuffer, int partitionId, int fragmentOffset, int fragmentLength, Runnable onCompleteHandler)
     

    Methods inherited from class java.lang.Object

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

    • ClaimedFragmentBatch

      public ClaimedFragmentBatch()
  • Method Details

    • wrap

      public void wrap(org.agrona.concurrent.UnsafeBuffer underlyingBuffer, int partitionId, int fragmentOffset, int fragmentLength, Runnable onCompleteHandler)
    • getBuffer

      public org.agrona.MutableDirectBuffer getBuffer()
      Returns:
      the claimed batch buffer to write in.
    • getFragmentOffset

      public int getFragmentOffset()
      Returns:
      the buffer offset of the last batch fragment
    • nextFragment

      public long nextFragment(int length, int streamId)
      Add a new fragment to the batch.
      Parameters:
      length - the length of the fragment
      streamId - the stream id of the fragment
      Returns:
      the position of the fragment
      Throws:
      IllegalArgumentException - if the given length is greater than the remaining capacity. In this case, you should try with smaller length, or abort the whole batch.
    • commit

      public void commit()
      Commit all fragments of the batch so that it can be read by subscriptions.
    • abort

      public void abort()
      Commit all fragments of the batch and mark them as failed. They will be ignored by subscriptions.