Package io.camunda.zeebe.dispatcher
Class Subscription
java.lang.Object
io.camunda.zeebe.dispatcher.Subscription
- All Implemented Interfaces:
ConsumableChannel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ActorConditionsprotected final ActorConditionprotected final intprotected booleanprotected final AtomicPositionstatic final org.slf4j.Loggerprotected final LogBufferprotected final Stringprotected final AtomicPositionprotected final ByteBuffer -
Constructor Summary
ConstructorsConstructorDescriptionSubscription(AtomicPosition position, AtomicPosition limit, int id, String name, ActorCondition onConsumption, LogBuffer logBuffer) -
Method Summary
Modifier and TypeMethodDescriptionprotected ActorConditionsintgetId()protected longgetLimit()getName()longbooleanintpeekAndConsume(FragmentHandler frgHandler, int maxNumOfFragments) Sequentially read fragments from the buffer and invoke the given handler for each fragment.intRead fragments from the buffer as block.protected intpeekBlock(LogBufferPartition partition, BlockPeek availableBlock, int partitionId, int partitionOffset, int maxBlockSize, long limit, boolean isStreamAware) intpoll(FragmentHandler frgHandler, int maxNumOfFragments) Read fragments from the buffer and invoke the given handler for each fragment.protected intpollFragments(LogBufferPartition partition, FragmentHandler frgHandler, int partitionId, int fragmentOffset, int maxNumOfFragments, long limit, boolean handlerControlled) voidregisterConsumer(ActorCondition consumer) voidremoveConsumer(ActorCondition consumer) toString()
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG -
actorConditions
-
limit
-
position
-
logBuffer
-
id
protected final int id -
name
-
dataConsumed
-
rawDispatcherBufferView
-
isClosed
protected volatile boolean isClosed
-
-
Constructor Details
-
Subscription
public Subscription(AtomicPosition position, AtomicPosition limit, int id, String name, ActorCondition onConsumption, LogBuffer logBuffer)
-
-
Method Details
-
getPosition
public long getPosition() -
hasAvailable
public boolean hasAvailable()- Specified by:
hasAvailablein interfaceConsumableChannel
-
registerConsumer
- Specified by:
registerConsumerin interfaceConsumableChannel
-
removeConsumer
- Specified by:
removeConsumerin interfaceConsumableChannel
-
getLimit
protected long getLimit() -
poll
Read fragments from the buffer and invoke the given handler for each fragment. Consume the fragments (i.e. update the subscription position) after all fragments are handled.Note that the handler is not aware of fragment batches.
- Returns:
- the amount of read fragments
-
pollFragments
protected int pollFragments(LogBufferPartition partition, FragmentHandler frgHandler, int partitionId, int fragmentOffset, int maxNumOfFragments, long limit, boolean handlerControlled) -
peekAndConsume
Sequentially read fragments from the buffer and invoke the given handler for each fragment. Consume the fragments (i.e. update the subscription position) depending on the return value ofFragmentHandler.onFragment(org.agrona.DirectBuffer, int, int, int, boolean). If a fragment is not consumed then no following fragments are read.Note that the handler is not aware of fragment batches.
- Returns:
- the amount of read fragments
-
peekBlock
Read fragments from the buffer as block. UseBlockPeek.getBuffer()to consume the fragments and finish the operation usingBlockPeek.markCompleted()orBlockPeek.markFailed().Note that the block only contains complete fragment batches.
- Parameters:
isStreamAware- iftrue, it stops reading fragments when a fragment has a different stream id than the previous one- Returns:
- amount of read bytes
-
peekBlock
protected int peekBlock(LogBufferPartition partition, BlockPeek availableBlock, int partitionId, int partitionOffset, int maxBlockSize, long limit, boolean isStreamAware) -
getId
public int getId() -
getName
-
getActorConditions
-
toString
-