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 CompletableFuture<Void>protected final CopyOnWriteArrayList<Consumer>protected final 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, hasFilter, subscription -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDispatcherSingleActiveConsumer(org.apache.pulsar.common.api.proto.CommandSubscribe.SubType subscriptionType, int partitionIndex, String topicName, Subscription subscription, ServiceConfiguration serviceConfig, ManagedCursor cursor) -
Method Summary
Modifier and TypeMethodDescriptionaddConsumer(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(boolean disconnectConsumers, Optional<BrokerLookupData> assignedBrokerLookupData) disconnectActiveConsumers(boolean isResetCursor) Disconnect active consumers.disconnectAllConsumers(boolean isResetCursor, Optional<BrokerLookupData> assignedBrokerLookupData) 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.voidremoveConsumer(Consumer consumer) voidreset()mark dispatcher open to serve new incoming requests.voidprotected abstract voidMethods inherited from class org.apache.pulsar.broker.service.AbstractBaseDispatcher
acquirePermitsForDeliveredMessages, checkAndApplyReachedEndOfTopicOrTopicMigration, checkAndApplyReachedEndOfTopicOrTopicMigration, computeReadLimits, filterEntriesForConsumer, filterEntriesForConsumer, getFilterAcceptedMsgCount, getFilterProcessedMsgCount, getFilterRejectedMsgCount, getFilterRescheduledMsgCount, getSubscriptionName, isConsumersExceededOnSubscription, isConsumersExceededOnSubscription, peekStickyKey, 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, afterAckMessages, checkAndResumeIfPaused, checkAndUnblockIfStuck, clearDelayedMessages, close, consumerFlow, cursorIsReset, disconnectAllConsumers, disconnectAllConsumers, getNumberOfDelayedMessages, getRateLimiter, getRedeliveryTracker, initializeDispatchRateLimiterIfNeeded, markDeletePositionMoveForward, redeliverUnacknowledgedMessages, redeliverUnacknowledgedMessages, trackDelayedDelivery, updateRateLimiter
-
Field Details
-
topicName
-
consumers
-
stickyKeyConsumerSelector
-
isKeyHashRangeFiltered
protected boolean isKeyHashRangeFiltered -
closeFuture
-
partitionIndex
protected final int partitionIndex -
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, ServiceConfiguration serviceConfig, ManagedCursor cursor)
-
-
Method Details
-
scheduleReadOnActiveConsumer
protected abstract void scheduleReadOnActiveConsumer() -
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
-
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
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
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()
-