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, ServiceConfiguration serviceConfig, ManagedCursor cursor)
  • Method Details

    • scheduleReadOnActiveConsumer

      protected abstract void scheduleReadOnActiveConsumer()
    • 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 CompletableFuture<Void> addConsumer(Consumer consumer)
    • 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(boolean disconnectConsumers, Optional<BrokerLookupData> assignedBrokerLookupData)
    • isClosed

      public boolean isClosed()
    • disconnectAllConsumers

      public CompletableFuture<Void> disconnectAllConsumers(boolean isResetCursor, Optional<BrokerLookupData> assignedBrokerLookupData)
      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.
      Parameters:
      isResetCursor - Specifies if the cursor has been reset.
      assignedBrokerLookupData - Optional target broker redirect information. Allows the consumer to quickly reconnect to a broker during bundle unloading.
      Returns:
      CompletableFuture indicating the completion of the operation.
    • 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()