Class PersistentStickyKeyDispatcherMultipleConsumers
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.PersistentDispatcherMultipleConsumers
org.apache.pulsar.broker.service.persistent.PersistentStickyKeyDispatcherMultipleConsumers
- All Implemented Interfaces:
AsyncCallbacks.ReadEntriesCallback,Dispatcher,StickyKeyDispatcher
public class PersistentStickyKeyDispatcherMultipleConsumers
extends PersistentDispatcherMultipleConsumers
implements StickyKeyDispatcher
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers
PersistentDispatcherMultipleConsumers.ReadType -
Field Summary
Fields inherited from class org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers
BLOCKED_DISPATCHER_ON_CURSOR_DATA_CAN_NOT_FULLY_PERSIST_UPDATER, BLOCKED_DISPATCHER_ON_UNACKMSG_UPDATER, cursor, dispatchMessagesThread, dispatchRateLimiter, havePendingRead, havePendingReplayRead, lastIndividualDeletedRangeFromCursorRecovery, lastNumberOfEntriesProcessed, minReplayedPosition, name, readBatchSize, readFailureBackoff, redeliveryMessages, redeliveryTracker, shouldRewindBeforeReadingOrReplaying, skipNextBackoff, 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 booleanThe dispatcher will skip replaying messages when all messages in the replay queue are filtered out when skipNextReplayToTriggerLookAhead=true.protected voidCreates a filter for replaying messages.protected booleanFor Key_Shared subscription, the dispatcher will not read more entries while there are pending reads or pending replay reads.org.apache.pulsar.common.api.proto.KeySharedModeprotected intSets a hard limit on the number of entries to read from the Managed Ledger.protected intgetStickyKeyHash(Entry entry) org.apache.pulsar.common.api.proto.CommandSubscribe.SubTypegetType()protected voidWhen a normal read is not allowed, the dispatcher will reschedule a read with a backoff.booleanhasSameKeySharedPolicy(org.apache.pulsar.common.api.proto.KeySharedMeta ksm) booleanprotected booleanFor Key_Shared subscription, the dispatcher will not attempt to read more entries if the replay queue size has reached the limit or if there are no consumers with permits.voidvoidremoveConsumer(Consumer consumer) protected booleantrySendMessagesToConsumers(PersistentDispatcherMultipleConsumers.ReadType readType, List<Entry> entries) Dispatch the messages to the Consumers.Methods inherited from class org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers
acquireSendInProgress, addEntryToReplay, addMessageToReplay, addMessageToReplay, addUnAckedMessages, afterAckMessages, asyncReplayEntriesInOrder, blockDispatcherOnUnackedMsgs, calculateToRead, cancelPendingRead, canUnsubscribe, checkAndResumeIfPaused, checkAndUnblockIfStuck, clearDelayedMessages, close, consumerFlow, createReadEntriesSkipConditionForNormalRead, cursorIsReset, disconnectActiveConsumers, disconnectAllConsumers, getBucketDelayedIndexStats, getConsumers, getCursor, getDelayedTrackerMemoryUsage, getFirstAvailableConsumerPermits, getFirstPositionInReplay, getMessagesToReplayNow, getName, getNumberOfDelayedMessages, getNumberOfMessagesInReplay, getRateLimiter, getReadMoreEntriesCallCount, getRedeliveryTracker, getSubscription, getTopic, getTotalUnackedMessages, initializeDispatchRateLimiterIfNeeded, internalRemoveConsumer, isAtleastOneConsumerAvailable, isBlockedDispatcherOnUnackedMsgs, isClassic, isConsumerAvailable, isConsumerConnected, isConsumersExceededOnSubscription, isHavePendingRead, isHavePendingReplayRead, isSendInProgress, readEntriesComplete, readEntriesFailed, readMoreEntries, readMoreEntriesAsync, redeliverUnacknowledgedMessages, redeliverUnacknowledgedMessages, releaseSendInProgress, reScheduleRead, reScheduleReadInMs, reScheduleReadWithBackoff, 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, getRecentlyJoinedConsumers, isClassic
-
Method Details
-
getSelector
- Specified by:
getSelectorin interfaceStickyKeyDispatcher
-
addConsumer
- Specified by:
addConsumerin interfaceDispatcher- Overrides:
addConsumerin classPersistentDispatcherMultipleConsumers
-
removeConsumer
- Specified by:
removeConsumerin interfaceDispatcher- Overrides:
removeConsumerin classPersistentDispatcherMultipleConsumers- Throws:
BrokerServiceException
-
clearComponentsAfterRemovedAllConsumers
protected void clearComponentsAfterRemovedAllConsumers()- Overrides:
clearComponentsAfterRemovedAllConsumersin classPersistentDispatcherMultipleConsumers
-
trySendMessagesToConsumers
protected boolean trySendMessagesToConsumers(PersistentDispatcherMultipleConsumers.ReadType readType, List<Entry> entries) Description copied from class:PersistentDispatcherMultipleConsumersDispatch the messages to the Consumers.- Overrides:
trySendMessagesToConsumersin classPersistentDispatcherMultipleConsumers- 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.
-
createFilterForReplay
Creates a filter for replaying messages. The filter is stateful and shouldn't be cached or reused.- Overrides:
createFilterForReplayin classPersistentDispatcherMultipleConsumers- See Also:
-
getStickyKeyHash
- Overrides:
getStickyKeyHashin classPersistentDispatcherMultipleConsumers
-
markDeletePositionMoveForward
public void markDeletePositionMoveForward()- Specified by:
markDeletePositionMoveForwardin interfaceDispatcher
-
canReplayMessages
protected boolean canReplayMessages()The dispatcher will skip replaying messages when all messages in the replay queue are filtered out when skipNextReplayToTriggerLookAhead=true. The flag gets resetted after the call. If we're stuck on replay, we want to move forward reading on the topic (until the configured look ahead limits kick in), instead of keep replaying the same old messages, since the consumer that these messages are routing to might be busy at the moment. Please seeServiceConfiguration.getKeySharedLookAheadMsgInReplayThresholdPerConsumer()andServiceConfiguration.getKeySharedLookAheadMsgInReplayThresholdPerSubscription()for configuring the limits.- Overrides:
canReplayMessagesin classPersistentDispatcherMultipleConsumers- Returns:
- true if replaying entries is currently enabled
-
doesntHavePendingRead
protected boolean doesntHavePendingRead()For Key_Shared subscription, the dispatcher will not read more entries while there are pending reads or pending replay reads.- Overrides:
doesntHavePendingReadin classPersistentDispatcherMultipleConsumers- Returns:
- true if there are no pending reads or pending replay reads
-
isNormalReadAllowed
protected boolean isNormalReadAllowed()For Key_Shared subscription, the dispatcher will not attempt to read more entries if the replay queue size has reached the limit or if there are no consumers with permits.- Overrides:
isNormalReadAllowedin classPersistentDispatcherMultipleConsumers
-
getMaxEntriesReadLimit
protected int getMaxEntriesReadLimit()Description copied from class:PersistentDispatcherMultipleConsumersSets a hard limit on the number of entries to read from the Managed Ledger. Subclasses can override this method to set a different limit. By default, this method does not impose an additional limit.- Overrides:
getMaxEntriesReadLimitin classPersistentDispatcherMultipleConsumers- Returns:
- the maximum number of entries to read from the Managed Ledger
-
handleNormalReadNotAllowed
protected void handleNormalReadNotAllowed()When a normal read is not allowed, the dispatcher will reschedule a read with a backoff.- Overrides:
handleNormalReadNotAllowedin classPersistentDispatcherMultipleConsumers
-
getType
public org.apache.pulsar.common.api.proto.CommandSubscribe.SubType getType()- Specified by:
getTypein interfaceDispatcher- Overrides:
getTypein classPersistentDispatcherMultipleConsumers
-
asyncReplayEntries
- Overrides:
asyncReplayEntriesin classPersistentDispatcherMultipleConsumers
-
isAllowOutOfOrderDelivery
public boolean isAllowOutOfOrderDelivery()- Specified by:
isAllowOutOfOrderDeliveryin interfaceStickyKeyDispatcher
-
getConsumerKeyHashRanges
- Specified by:
getConsumerKeyHashRangesin interfaceStickyKeyDispatcher
-