Class AbstractDispatcherSingleActiveConsumer

All Implemented Interfaces:
Dispatcher
Direct Known Subclasses:
NonPersistentDispatcherSingleActiveConsumer, PersistentDispatcherSingleActiveConsumer

public abstract class AbstractDispatcherSingleActiveConsumer extends AbstractBaseDispatcher
  • Field Details

  • Constructor Details

    • AbstractDispatcherSingleActiveConsumer

      public AbstractDispatcherSingleActiveConsumer(org.apache.pulsar.common.api.proto.CommandSubscribe.SubType subscriptionType, int partitionIndex, String topicName, Subscription subscription, org.apache.pulsar.broker.ServiceConfiguration serviceConfig, org.apache.bookkeeper.mledger.ManagedCursor cursor)
  • Method Details

    • scheduleReadOnActiveConsumer

      protected abstract void scheduleReadOnActiveConsumer()
    • readMoreEntries

      protected abstract void readMoreEntries(Consumer consumer)
    • cancelPendingRead

      protected abstract void cancelPendingRead()
    • notifyActiveConsumerChanged

      protected void notifyActiveConsumerChanged(Consumer activeConsumer)
    • pickAndScheduleActiveConsumer

      protected boolean pickAndScheduleActiveConsumer()
      Pick active consumer for a topic for CommandSubscribe.SubType.Failover subscription. If it's a non-partitioned topic then it'll pick consumer based on order they subscribe to the topic. If is's a partitioned topic, first sort consumers based on their priority level and consumer name then distributed partitions evenly across consumers with highest priority level.
      Returns:
      the true consumer if the consumer is changed, otherwise false.
    • addConsumer

      public void addConsumer(Consumer consumer) throws BrokerServiceException
      Throws:
      BrokerServiceException
    • removeConsumer

      public void removeConsumer(Consumer consumer) throws BrokerServiceException
      Throws:
      BrokerServiceException
    • canUnsubscribe

      public boolean canUnsubscribe(Consumer consumer)
      Handle unsubscribe command from the client API For failover subscription, if consumer is connected consumer, we can unsubscribe.
      Parameters:
      consumer - Calling consumer object
    • close

      public CompletableFuture<Void> close()
      Description copied from interface: Dispatcher
      mark dispatcher closed to stop new incoming requests and disconnect all consumers.
      Returns:
    • isClosed

      public boolean isClosed()
    • disconnectAllConsumers

      public CompletableFuture<Void> disconnectAllConsumers(boolean isResetCursor)
      Disconnect all consumers on this dispatcher (server side close). This triggers channelInactive on the inbound handler which calls dispatcher.removeConsumer(), where the closeFuture is completed
      Returns:
    • disconnectActiveConsumers

      public CompletableFuture<Void> disconnectActiveConsumers(boolean isResetCursor)
      Description copied from interface: Dispatcher
      Disconnect active consumers.
    • resetCloseFuture

      public void resetCloseFuture()
      Specified by:
      resetCloseFuture in interface Dispatcher
      Overrides:
      resetCloseFuture in class AbstractBaseDispatcher
    • reset

      public void reset()
      Description copied from interface: Dispatcher
      mark dispatcher open to serve new incoming requests.
    • getType

      public org.apache.pulsar.common.api.proto.CommandSubscribe.SubType getType()
    • getActiveConsumer

      public Consumer getActiveConsumer()
    • getConsumers

      public List<Consumer> getConsumers()
    • isConsumerConnected

      public boolean isConsumerConnected()