Class MessageDeduplication
- java.lang.Object
-
- org.apache.pulsar.broker.service.persistent.MessageDeduplication
-
public class MessageDeduplication extends java.lang.ObjectClass that contains all the logic to control and perform the deduplication on the broker side.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMessageDeduplication.MessageDupStatusstatic classMessageDeduplication.MessageDupUnknownException
-
Constructor Summary
Constructors Constructor Description MessageDeduplication(PulsarService pulsar, PersistentTopic topic, org.apache.bookkeeper.mledger.ManagedLedger managedLedger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.Void>checkStatus()Check the status of deduplication.longgetLastPublishedSequenceId(java.lang.String producerName)org.apache.pulsar.broker.service.persistent.MessageDeduplication.StatusgetStatus()MessageDeduplication.MessageDupStatusisDuplicate(Topic.PublishContext publishContext, io.netty.buffer.ByteBuf headersAndPayload)Assess whether the message was already stored in the topic.booleanisEnabled()voidproducerAdded(java.lang.String producerName)Topic will call this method whenever a producer connects.voidproducerRemoved(java.lang.String producerName)Topic will call this method whenever a producer disconnects.voidpurgeInactiveProducers()Remove 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.voidresetHighestSequenceIdPushed()voidtakeSnapshot()
-
-
-
Constructor Detail
-
MessageDeduplication
public MessageDeduplication(PulsarService pulsar, PersistentTopic topic, org.apache.bookkeeper.mledger.ManagedLedger managedLedger)
-
-
Method Detail
-
getStatus
public org.apache.pulsar.broker.service.persistent.MessageDeduplication.Status getStatus()
-
checkStatus
public java.util.concurrent.CompletableFuture<java.lang.Void> 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
public void producerAdded(java.lang.String producerName)
Topic will call this method whenever a producer connects.
-
producerRemoved
public void producerRemoved(java.lang.String producerName)
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
public long getLastPublishedSequenceId(java.lang.String producerName)
-
takeSnapshot
public void takeSnapshot()
-
-