Package io.camunda.zeebe.dispatcher
Class ClaimedFragmentBatch
java.lang.Object
io.camunda.zeebe.dispatcher.ClaimedFragmentBatch
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Commit all fragments of the batch and mark them as failed.voidcommit()Commit all fragments of the batch so that it can be read by subscriptions.org.agrona.MutableDirectBufferintlongnextFragment(int length, int streamId) Add a new fragment to the batch.voidwrap(org.agrona.concurrent.UnsafeBuffer underlyingBuffer, int partitionId, int fragmentOffset, int fragmentLength, Runnable onCompleteHandler)
-
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 fragmentstreamId- 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.
-