Package org.apache.pulsar.broker.service
Class AbstractDispatcherSingleActiveConsumer
java.lang.Object
org.apache.pulsar.broker.service.EntryFilterSupport
org.apache.pulsar.broker.service.AbstractBaseDispatcher
org.apache.pulsar.broker.service.AbstractDispatcherSingleActiveConsumer
- All Implemented Interfaces:
Dispatcher
- Direct Known Subclasses:
NonPersistentDispatcherSingleActiveConsumer,PersistentDispatcherSingleActiveConsumer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final AtomicReferenceFieldUpdater<AbstractDispatcherSingleActiveConsumer,Consumer> protected CompletableFuture<Void>protected final CopyOnWriteArrayList<Consumer>protected final org.apache.bookkeeper.mledger.ManagedCursorprotected static final intprotected static final AtomicIntegerFieldUpdater<AbstractDispatcherSingleActiveConsumer>protected booleanprotected booleanprotected final intprotected StickyKeyConsumerSelectorprotected final org.apache.pulsar.common.api.proto.CommandSubscribe.SubTypeprotected final Stringprotected static final intFields inherited from class org.apache.pulsar.broker.service.AbstractBaseDispatcher
dispatchThrottlingOnBatchMessageEnabled, serviceConfigFields inherited from class org.apache.pulsar.broker.service.EntryFilterSupport
entryFilters, filterContext, subscription -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDispatcherSingleActiveConsumer(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 Summary
Modifier and TypeMethodDescriptionvoidaddConsumer(Consumer consumer) protected abstract voidbooleancanUnsubscribe(Consumer consumer) Handle unsubscribe command from the client API For failover subscription, if consumer is connected consumer, we can unsubscribe.close()mark dispatcher closed to stop new incoming requests and disconnect all consumers.disconnectActiveConsumers(boolean isResetCursor) Disconnect active consumers.disconnectAllConsumers(boolean isResetCursor) Disconnect all consumers on this dispatcher (server side close).org.apache.pulsar.common.api.proto.CommandSubscribe.SubTypegetType()booleanisClosed()booleanprotected voidnotifyActiveConsumerChanged(Consumer activeConsumer) protected booleanPick active consumer for a topic forCommandSubscribe.SubType.Failoversubscription.protected abstract voidreadMoreEntries(Consumer consumer) voidremoveConsumer(Consumer consumer) voidreset()mark dispatcher open to serve new incoming requests.voidprotected abstract voidMethods inherited from class org.apache.pulsar.broker.service.AbstractBaseDispatcher
computeReadLimits, filterEntriesForConsumer, filterEntriesForConsumer, getFilterAcceptedMsgCount, getFilterProcessedMsgCount, getFilterRejectedMsgCount, getFilterRescheduledMsgCount, getSubscriptionName, isConsumersExceededOnSubscription, isConsumersExceededOnSubscription, peekStickyKey, reachDispatchRateLimit, reScheduleRead, updateMessagesToRead, updatePendingBytesToDispatchMethods inherited from class org.apache.pulsar.broker.service.EntryFilterSupport
runFiltersForEntryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pulsar.broker.service.Dispatcher
addUnAckedMessages, checkAndUnblockIfStuck, clearDelayedMessages, consumerFlow, cursorIsReset, disconnectAllConsumers, getNumberOfDelayedMessages, getRateLimiter, getRedeliveryTracker, initializeDispatchRateLimiterIfNeeded, markDeletePositionMoveForward, redeliverUnacknowledgedMessages, redeliverUnacknowledgedMessages, trackDelayedDelivery, updateRateLimiter
-
Field Details
-
topicName
-
ACTIVE_CONSUMER_UPDATER
protected static final AtomicReferenceFieldUpdater<AbstractDispatcherSingleActiveConsumer,Consumer> ACTIVE_CONSUMER_UPDATER -
consumers
-
stickyKeyConsumerSelector
-
isKeyHashRangeFiltered
protected boolean isKeyHashRangeFiltered -
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 -
FALSE
protected static final int FALSE- See Also:
-
TRUE
protected static final int TRUE- See Also:
-
IS_CLOSED_UPDATER
protected static final AtomicIntegerFieldUpdater<AbstractDispatcherSingleActiveConsumer> IS_CLOSED_UPDATER -
isFirstRead
protected boolean isFirstRead
-
-
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
-
cancelPendingRead
protected abstract void cancelPendingRead() -
notifyActiveConsumerChanged
-
pickAndScheduleActiveConsumer
protected boolean pickAndScheduleActiveConsumer()Pick active consumer for a topic forCommandSubscribe.SubType.Failoversubscription. 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
- Throws:
BrokerServiceException
-
removeConsumer
- Throws:
BrokerServiceException
-
canUnsubscribe
Handle unsubscribe command from the client API For failover subscription, if consumer is connected consumer, we can unsubscribe.- Parameters:
consumer- Calling consumer object
-
close
Description copied from interface:Dispatchermark dispatcher closed to stop new incoming requests and disconnect all consumers.- Returns:
-
isClosed
public boolean isClosed() -
disconnectAllConsumers
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
Description copied from interface:DispatcherDisconnect active consumers. -
resetCloseFuture
public void resetCloseFuture()- Specified by:
resetCloseFuturein interfaceDispatcher- Overrides:
resetCloseFuturein classAbstractBaseDispatcher
-
reset
public void reset()Description copied from interface:Dispatchermark dispatcher open to serve new incoming requests. -
getType
public org.apache.pulsar.common.api.proto.CommandSubscribe.SubType getType() -
getActiveConsumer
-
getConsumers
-
isConsumerConnected
public boolean isConsumerConnected()
-