Class MessageDeduplication
java.lang.Object
org.apache.pulsar.broker.service.persistent.MessageDeduplication
Class that contains all the logic to control and perform the deduplication on the broker side.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic class -
Constructor Summary
ConstructorsConstructorDescriptionMessageDeduplication(PulsarService pulsar, PersistentTopic topic, org.apache.bookkeeper.mledger.ManagedLedger managedLedger) -
Method Summary
Modifier and TypeMethodDescriptionCheck the status of deduplication.longgetLastPublishedSequenceId(String producerName) org.apache.pulsar.broker.service.persistent.MessageDeduplication.StatusisDuplicate(Topic.PublishContext publishContext, io.netty.buffer.ByteBuf headersAndPayload) Assess whether the message was already stored in the topic.booleanvoidproducerAdded(String producerName) Topic will call this method whenever a producer connects.voidproducerRemoved(String producerName) Topic will call this method whenever a producer disconnects.voidRemove from hash maps all the producers that were inactive for more than the configured amount of time.voidrecordMessagePersisted(Topic.PublishContext publishContext, org.apache.bookkeeper.mledger.impl.PositionImpl position) Call this method whenever a message is persisted to get the chance to trigger a snapshot.voidvoid
-
Constructor Details
-
MessageDeduplication
public MessageDeduplication(PulsarService pulsar, PersistentTopic topic, org.apache.bookkeeper.mledger.ManagedLedger managedLedger)
-
-
Method Details
-
getStatus
public org.apache.pulsar.broker.service.persistent.MessageDeduplication.Status getStatus() -
checkStatus
Check the status of deduplication. If the configuration has changed, it will enable/disable deduplication, returning a future to track the completion of the task -
isEnabled
public boolean isEnabled() -
isDuplicate
public MessageDeduplication.MessageDupStatus isDuplicate(Topic.PublishContext publishContext, io.netty.buffer.ByteBuf headersAndPayload) Assess whether the message was already stored in the topic.- Returns:
- true if the message should be published or false if it was recognized as a duplicate
-
recordMessagePersisted
public void recordMessagePersisted(Topic.PublishContext publishContext, org.apache.bookkeeper.mledger.impl.PositionImpl position) Call this method whenever a message is persisted to get the chance to trigger a snapshot. -
resetHighestSequenceIdPushed
public void resetHighestSequenceIdPushed() -
producerAdded
Topic will call this method whenever a producer connects. -
producerRemoved
Topic will call this method whenever a producer disconnects. -
purgeInactiveProducers
public void purgeInactiveProducers()Remove from hash maps all the producers that were inactive for more than the configured amount of time. -
getLastPublishedSequenceId
-
takeSnapshot
public void takeSnapshot()
-