Package org.apache.pulsar.broker.service
Class AbstractBaseDispatcher
- java.lang.Object
-
- org.apache.pulsar.broker.service.AbstractBaseDispatcher
-
- All Implemented Interfaces:
Dispatcher
- Direct Known Subclasses:
AbstractDispatcherMultipleConsumers,AbstractDispatcherSingleActiveConsumer
public abstract class AbstractBaseDispatcher extends java.lang.Object implements Dispatcher
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.pulsar.broker.ServiceConfigurationserviceConfigprotected Subscriptionsubscription
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractBaseDispatcher(Subscription subscription, org.apache.pulsar.broker.ServiceConfiguration serviceConfig)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static org.apache.commons.lang3.tuple.Pair<java.lang.Integer,java.lang.Long>computeReadLimits(int messagesToRead, int availablePermitsOnMsg, long bytesToRead, long availablePermitsOnByte)voidfilterEntriesForConsumer(java.util.List<org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, SendMessageInfo sendMessageInfo, EntryBatchIndexesAcks indexesAcks, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean isReplayRead)Filter messages that are being sent to a consumers.voidfilterEntriesForConsumer(java.util.Optional<EntryWrapper[]> entryWrapper, int entryWrapperOffset, java.util.List<org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, SendMessageInfo sendMessageInfo, EntryBatchIndexesAcks indexesAcks, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean isReplayRead)protected abstract booleanisConsumersExceededOnSubscription()Determine whether the number of consumers on the subscription reaches the threshold.protected booleanisConsumersExceededOnSubscription(BrokerService brokerService, AbstractTopic topic, int consumerSize)protected byte[]peekStickyKey(io.netty.buffer.ByteBuf metadataAndPayload)voidresetCloseFuture()protected intupdateEntryWrapperWithMetadata(EntryWrapper[] entryWrappers, java.util.List<org.apache.bookkeeper.mledger.Entry> entries)Update Entries with the metadata of each entry.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pulsar.broker.service.Dispatcher
addConsumer, addUnAckedMessages, canUnsubscribe, checkAndUnblockIfStuck, clearDelayedMessages, close, consumerFlow, cursorIsReset, disconnectActiveConsumers, disconnectAllConsumers, disconnectAllConsumers, getConsumers, getNumberOfDelayedMessages, getRateLimiter, getRedeliveryTracker, getType, initializeDispatchRateLimiterIfNeeded, isClosed, isConsumerConnected, markDeletePositionMoveForward, redeliverUnacknowledgedMessages, redeliverUnacknowledgedMessages, removeConsumer, reset, trackDelayedDelivery, updateRateLimiter
-
-
-
-
Field Detail
-
subscription
protected final Subscription subscription
-
serviceConfig
protected final org.apache.pulsar.broker.ServiceConfiguration serviceConfig
-
-
Constructor Detail
-
AbstractBaseDispatcher
protected AbstractBaseDispatcher(Subscription subscription, org.apache.pulsar.broker.ServiceConfiguration serviceConfig)
-
-
Method Detail
-
updateEntryWrapperWithMetadata
protected int updateEntryWrapperWithMetadata(EntryWrapper[] entryWrappers, java.util.List<org.apache.bookkeeper.mledger.Entry> entries)
Update Entries with the metadata of each entry.- Parameters:
entries-- Returns:
-
filterEntriesForConsumer
public void filterEntriesForConsumer(java.util.List<org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, SendMessageInfo sendMessageInfo, EntryBatchIndexesAcks indexesAcks, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean isReplayRead)Filter messages that are being sent to a consumers.Messages can be filtered out for multiple reasons:
- Checksum or metadata corrupted
- Message is an internal marker
- Message is not meant to be delivered immediately
- Parameters:
entries- a list of entries as read from storagebatchSizes- an array where the batch size for each entry (the number of messages within an entry) is stored. This array needs to be of at least the same size as the entries listsendMessageInfo- an object where the total size in messages and bytes will be returned back to the caller
-
filterEntriesForConsumer
public void filterEntriesForConsumer(java.util.Optional<EntryWrapper[]> entryWrapper, int entryWrapperOffset, java.util.List<org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, SendMessageInfo sendMessageInfo, EntryBatchIndexesAcks indexesAcks, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean isReplayRead)
-
isConsumersExceededOnSubscription
protected abstract boolean isConsumersExceededOnSubscription()
Determine whether the number of consumers on the subscription reaches the threshold.- Returns:
-
isConsumersExceededOnSubscription
protected boolean isConsumersExceededOnSubscription(BrokerService brokerService, AbstractTopic topic, int consumerSize)
-
resetCloseFuture
public void resetCloseFuture()
- Specified by:
resetCloseFuturein interfaceDispatcher
-
computeReadLimits
protected static org.apache.commons.lang3.tuple.Pair<java.lang.Integer,java.lang.Long> computeReadLimits(int messagesToRead, int availablePermitsOnMsg, long bytesToRead, long availablePermitsOnByte)
-
peekStickyKey
protected byte[] peekStickyKey(io.netty.buffer.ByteBuf metadataAndPayload)
-
-