Class Subscription

java.lang.Object
io.camunda.zeebe.dispatcher.Subscription
All Implemented Interfaces:
ConsumableChannel

public class Subscription extends Object implements ConsumableChannel
  • Field Details

    • LOG

      public static final org.slf4j.Logger LOG
    • actorConditions

      protected final ActorConditions actorConditions
    • limit

      protected final AtomicPosition limit
    • position

      protected final AtomicPosition position
    • logBuffer

      protected final LogBuffer logBuffer
    • id

      protected final int id
    • name

      protected final String name
    • dataConsumed

      protected final ActorCondition dataConsumed
    • rawDispatcherBufferView

      protected final ByteBuffer rawDispatcherBufferView
    • isClosed

      protected volatile boolean isClosed
  • Constructor Details

  • Method Details

    • getPosition

      public long getPosition()
    • hasAvailable

      public boolean hasAvailable()
      Specified by:
      hasAvailable in interface ConsumableChannel
    • registerConsumer

      public void registerConsumer(ActorCondition consumer)
      Specified by:
      registerConsumer in interface ConsumableChannel
    • removeConsumer

      public void removeConsumer(ActorCondition consumer)
      Specified by:
      removeConsumer in interface ConsumableChannel
    • getLimit

      protected long getLimit()
    • poll

      public int poll(FragmentHandler frgHandler, int maxNumOfFragments)
      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

      public int peekAndConsume(FragmentHandler frgHandler, int maxNumOfFragments)
      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 of FragmentHandler.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

      public int peekBlock(BlockPeek availableBlock, int maxBlockSize, boolean isStreamAware)
      Read fragments from the buffer as block. Use BlockPeek.getBuffer() to consume the fragments and finish the operation using BlockPeek.markCompleted() or BlockPeek.markFailed().

      Note that the block only contains complete fragment batches.

      Parameters:
      isStreamAware - if true, 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

      public String getName()
    • getActorConditions

      protected ActorConditions getActorConditions()
    • toString

      public String toString()
      Overrides:
      toString in class Object