Class PersistentStickyKeyDispatcherMultipleConsumersClassic
java.lang.Object
org.apache.pulsar.broker.service.EntryFilterSupport
org.apache.pulsar.broker.service.AbstractBaseDispatcher
org.apache.pulsar.broker.service.AbstractDispatcherMultipleConsumers
org.apache.pulsar.broker.service.persistent.AbstractPersistentDispatcherMultipleConsumers
org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumersClassic
org.apache.pulsar.broker.service.persistent.PersistentStickyKeyDispatcherMultipleConsumersClassic
- All Implemented Interfaces:
AsyncCallbacks.ReadEntriesCallback,Dispatcher,StickyKeyDispatcher
public class PersistentStickyKeyDispatcherMultipleConsumersClassic
extends PersistentDispatcherMultipleConsumersClassic
implements StickyKeyDispatcher
This is the "classic" dispatcher implementation for the Key_Shared subscription that was used before
Pulsar 4.0.0 and PIP-379. When `subscriptionKeySharedUseClassicPersistentImplementation=true`,
this dispatcher will be used. The main purpose is to provide a way to rollback to the old behavior
in case of issues with the preferred implementation.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumersClassic
PersistentDispatcherMultipleConsumersClassic.ReadType -
Field Summary
Fields inherited from class org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumersClassic
BLOCKED_DISPATCHER_ON_CURSOR_DATA_CAN_NOT_FULLY_PERSIST_UPDATER, BLOCKED_DISPATCHER_ON_UNACKMSG_UPDATER, cursor, dispatchMessagesThread, dispatchRateLimiter, havePendingRead, havePendingReplayRead, lastIndividualDeletedRangeFromCursorRecovery, minReplayedPosition, name, readBatchSize, readFailureBackoff, redeliveryMessages, redeliveryTracker, shouldRewindBeforeReadingOrReplaying, topic, TOTAL_AVAILABLE_PERMITS_UPDATER, totalAvailablePermits, totalUnackedMessagesFields inherited from class org.apache.pulsar.broker.service.AbstractDispatcherMultipleConsumers
consumerList, consumerSet, currentConsumerRoundRobinIndex, FALSE, IS_CLOSED_UPDATER, TRUEFields inherited from class org.apache.pulsar.broker.service.AbstractBaseDispatcher
dispatchThrottlingOnBatchMessageEnabled, serviceConfigFields inherited from class org.apache.pulsar.broker.service.EntryFilterSupport
entryFilters, filterContext, hasFilter, subscription -
Method Summary
Modifier and TypeMethodDescriptionaddConsumer(Consumer consumer) asyncReplayEntries(Set<? extends Position> positions) protected NavigableSet<Position>This is a mode method designed for Key_Shared mode.org.apache.pulsar.common.api.proto.KeySharedModeprotected NavigableSet<Position>getMessagesToReplayNow(int maxMessagesToRead) protected intgetStickyKeyHash(Entry entry) org.apache.pulsar.common.api.proto.CommandSubscribe.SubTypegetType()protected booleanIn Key_Shared mode, the consumer will not receive any entries from a normal reading if it is included inrecentlyJoinedConsumers, they can only receive entries from replay reads.booleanhasSameKeySharedPolicy(org.apache.pulsar.common.api.proto.KeySharedMeta ksm) booleanvoidvoidremoveConsumer(Consumer consumer) protected booleantrySendMessagesToConsumers(PersistentDispatcherMultipleConsumersClassic.ReadType readType, List<Entry> entries) Dispatch the messages to the Consumers.Methods inherited from class org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumersClassic
acquireSendInProgress, addMessageToReplay, addMessageToReplay, addUnAckedMessages, afterAckMessages, asyncReplayEntriesInOrder, blockDispatcherOnUnackedMsgs, calculateToRead, cancelPendingRead, canUnsubscribe, checkAndResumeIfPaused, checkAndUnblockIfStuck, clearDelayedMessages, close, consumerFlow, cursorIsReset, disconnectActiveConsumers, disconnectAllConsumers, getBucketDelayedIndexStats, getConsumers, getCursor, getDelayedTrackerMemoryUsage, getFirstAvailableConsumerPermits, getName, getNumberOfDelayedMessages, getNumberOfMessagesInReplay, getRateLimiter, getRedeliveryTracker, getSubscription, getTopic, getTotalUnackedMessages, initializeDispatchRateLimiterIfNeeded, isAtleastOneConsumerAvailable, isBlockedDispatcherOnUnackedMsgs, isClassic, isConsumerAvailable, isConsumerConnected, isConsumersExceededOnSubscription, isHavePendingRead, isHavePendingReplayRead, isSendInProgress, readEntriesComplete, readEntriesFailed, readMoreEntries, readMoreEntriesAsync, redeliverUnacknowledgedMessages, redeliverUnacknowledgedMessages, releaseSendInProgress, reScheduleRead, reset, resetCloseFuture, sendMessagesToConsumers, shouldPauseDeliveryForDelayTracker, trackDelayedDelivery, unBlockDispatcherOnUnackedMsgsMethods inherited from class org.apache.pulsar.broker.service.AbstractDispatcherMultipleConsumers
getNextConsumer, getRandomConsumer, isClosedMethods inherited from class org.apache.pulsar.broker.service.AbstractBaseDispatcher
acquirePermitsForDeliveredMessages, checkAndApplyReachedEndOfTopicOrTopicMigration, checkAndApplyReachedEndOfTopicOrTopicMigration, computeReadLimits, filterEntriesForConsumer, filterEntriesForConsumer, getFilterAcceptedMsgCount, getFilterProcessedMsgCount, getFilterRejectedMsgCount, getFilterRescheduledMsgCount, getSubscriptionName, isConsumersExceededOnSubscription, peekStickyKey, 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, canUnsubscribe, checkAndResumeIfPaused, checkAndUnblockIfStuck, clearDelayedMessages, close, close, consumerFlow, cursorIsReset, disconnectActiveConsumers, disconnectAllConsumers, disconnectAllConsumers, disconnectAllConsumers, getConsumers, getFilterAcceptedMsgCount, getFilterProcessedMsgCount, getFilterRejectedMsgCount, getFilterRescheduledMsgCount, getNumberOfDelayedMessages, getRateLimiter, getRedeliveryTracker, initializeDispatchRateLimiterIfNeeded, isClosed, isConsumerConnected, redeliverUnacknowledgedMessages, redeliverUnacknowledgedMessages, reset, resetCloseFuture, trackDelayedDelivery, updateRateLimiterMethods inherited from interface org.apache.pulsar.broker.service.StickyKeyDispatcher
getNumberOfMessagesInReplay, isClassic
-
Method Details
-
getSelector
- Specified by:
getSelectorin interfaceStickyKeyDispatcher
-
addConsumer
- Specified by:
addConsumerin interfaceDispatcher- Overrides:
addConsumerin classPersistentDispatcherMultipleConsumersClassic
-
removeConsumer
- Specified by:
removeConsumerin interfaceDispatcher- Overrides:
removeConsumerin classPersistentDispatcherMultipleConsumersClassic- Throws:
BrokerServiceException
-
trySendMessagesToConsumers
protected boolean trySendMessagesToConsumers(PersistentDispatcherMultipleConsumersClassic.ReadType readType, List<Entry> entries) Description copied from class:PersistentDispatcherMultipleConsumersClassicDispatch the messages to the Consumers.- Overrides:
trySendMessagesToConsumersin classPersistentDispatcherMultipleConsumersClassic- Returns:
- true if you want to trigger a new read. This method is overridden by other classes, please take a look to other implementations if you need to change it.
-
markDeletePositionMoveForward
public void markDeletePositionMoveForward()- Specified by:
markDeletePositionMoveForwardin interfaceDispatcher
-
getMessagesToReplayNow
- Overrides:
getMessagesToReplayNowin classPersistentDispatcherMultipleConsumersClassic
-
hasConsumersNeededNormalRead
protected boolean hasConsumersNeededNormalRead()In Key_Shared mode, the consumer will not receive any entries from a normal reading if it is included inrecentlyJoinedConsumers, they can only receive entries from replay reads. If all entries inPersistentDispatcherMultipleConsumersClassic.redeliveryMessageshave been filtered out due to the order guarantee mechanism, Broker need a normal read to make the consumers not included in @link #recentlyJoinedConsumers} will not be stuck. See https://github.com/apache/pulsar/pull/7105.- Overrides:
hasConsumersNeededNormalReadin classPersistentDispatcherMultipleConsumersClassic
-
getType
public org.apache.pulsar.common.api.proto.CommandSubscribe.SubType getType()- Specified by:
getTypein interfaceDispatcher- Overrides:
getTypein classPersistentDispatcherMultipleConsumersClassic
-
asyncReplayEntries
- Overrides:
asyncReplayEntriesin classPersistentDispatcherMultipleConsumersClassic
-
isAllowOutOfOrderDelivery
public boolean isAllowOutOfOrderDelivery()- Specified by:
isAllowOutOfOrderDeliveryin interfaceStickyKeyDispatcher
-
getRecentlyJoinedConsumers
- Specified by:
getRecentlyJoinedConsumersin interfaceStickyKeyDispatcher
-
getConsumerKeyHashRanges
- Specified by:
getConsumerKeyHashRangesin interfaceStickyKeyDispatcher
-
getStickyKeyHash
- Overrides:
getStickyKeyHashin classPersistentDispatcherMultipleConsumersClassic
-