Class AbstractBaseDispatcher

java.lang.Object
org.apache.pulsar.broker.service.EntryFilterSupport
org.apache.pulsar.broker.service.AbstractBaseDispatcher
All Implemented Interfaces:
Dispatcher
Direct Known Subclasses:
AbstractDispatcherMultipleConsumers, AbstractDispatcherSingleActiveConsumer

public abstract class AbstractBaseDispatcher extends EntryFilterSupport implements Dispatcher
  • Field Details

    • serviceConfig

      protected final org.apache.pulsar.broker.ServiceConfiguration serviceConfig
    • dispatchThrottlingOnBatchMessageEnabled

      protected final boolean dispatchThrottlingOnBatchMessageEnabled
  • Constructor Details

    • AbstractBaseDispatcher

      protected AbstractBaseDispatcher(Subscription subscription, org.apache.pulsar.broker.ServiceConfiguration serviceConfig)
  • Method Details

    • filterEntriesForConsumer

      public int filterEntriesForConsumer(List<? extends org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, SendMessageInfo sendMessageInfo, EntryBatchIndexesAcks indexesAcks, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean isReplayRead, Consumer consumer)
      Filter messages that are being sent to a consumers.

      Messages can be filtered out for multiple reasons:

      • Checksum or metadata corrupted
      • Message is an internal marker
      • Message is not meant to be delivered immediately
      Parameters:
      entries - a list of entries as read from storage
      batchSizes - an array where the batch size for each entry (the number of messages within an entry) is stored. This array needs to be of at least the same size as the entries list
      sendMessageInfo - an object where the total size in messages and bytes will be returned back to the caller
    • filterEntriesForConsumer

      public int filterEntriesForConsumer(@Nullable org.apache.pulsar.common.api.proto.MessageMetadata[] metadataArray, int startOffset, List<? extends org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, SendMessageInfo sendMessageInfo, EntryBatchIndexesAcks indexesAcks, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean isReplayRead, Consumer consumer)
      Filter entries with prefetched message metadata range so that there is no need to peek metadata from Entry.
      Parameters:
      metadataArray - the optional message metadata array. need check if null pass.
      startOffset - the index in `optMetadataArray` of the first Entry's message metadata
      See Also:
    • isConsumersExceededOnSubscription

      protected abstract boolean isConsumersExceededOnSubscription()
      Determine whether the number of consumers on the subscription reaches the threshold.
      Returns:
    • isConsumersExceededOnSubscription

      protected boolean isConsumersExceededOnSubscription(AbstractTopic topic, int consumerSize)
    • resetCloseFuture

      public void resetCloseFuture()
      Specified by:
      resetCloseFuture in interface Dispatcher
    • reScheduleRead

      protected abstract void reScheduleRead()
    • reachDispatchRateLimit

      protected boolean reachDispatchRateLimit(DispatchRateLimiter dispatchRateLimiter)
    • updateMessagesToRead

      protected org.apache.commons.lang3.tuple.Pair<Integer,Long> updateMessagesToRead(DispatchRateLimiter dispatchRateLimiter, int messagesToRead, long bytesToRead)
    • computeReadLimits

      protected static org.apache.commons.lang3.tuple.Pair<Integer,Long> computeReadLimits(int messagesToRead, int availablePermitsOnMsg, long bytesToRead, long availablePermitsOnByte)
    • peekStickyKey

      protected byte[] peekStickyKey(io.netty.buffer.ByteBuf metadataAndPayload)
    • getSubscriptionName

      protected String getSubscriptionName()
    • getFilterProcessedMsgCount

      public long getFilterProcessedMsgCount()
      Specified by:
      getFilterProcessedMsgCount in interface Dispatcher
    • getFilterAcceptedMsgCount

      public long getFilterAcceptedMsgCount()
      Specified by:
      getFilterAcceptedMsgCount in interface Dispatcher
    • getFilterRejectedMsgCount

      public long getFilterRejectedMsgCount()
      Specified by:
      getFilterRejectedMsgCount in interface Dispatcher
    • getFilterRescheduledMsgCount

      public long getFilterRescheduledMsgCount()
      Specified by:
      getFilterRescheduledMsgCount in interface Dispatcher
    • updatePendingBytesToDispatch

      protected final void updatePendingBytesToDispatch(long size)