Class AbstractDispatcherSingleActiveConsumer

    • Field Detail

      • topicName

        protected final java.lang.String topicName
      • consumers

        protected final java.util.concurrent.CopyOnWriteArrayList<Consumer> consumers
      • isKeyHashRangeFiltered

        protected boolean isKeyHashRangeFiltered
      • closeFuture

        protected java.util.concurrent.CompletableFuture<java.lang.Void> closeFuture
      • partitionIndex

        protected final int partitionIndex
      • cursor

        protected final org.apache.bookkeeper.mledger.ManagedCursor cursor
      • subscriptionType

        protected final org.apache.pulsar.common.api.proto.CommandSubscribe.SubType subscriptionType
      • isFirstRead

        protected boolean isFirstRead
    • Constructor Detail

      • AbstractDispatcherSingleActiveConsumer

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

      • 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.
      • 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 java.util.concurrent.CompletableFuture<java.lang.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 java.util.concurrent.CompletableFuture<java.lang.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 java.util.concurrent.CompletableFuture<java.lang.Void> disconnectActiveConsumers​(boolean isResetCursor)
        Description copied from interface: Dispatcher
        Disconnect active consumers.
      • 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 java.util.List<Consumer> getConsumers()
      • isConsumerConnected

        public boolean isConsumerConnected()