Class AbstractReplicator

java.lang.Object
org.apache.pulsar.broker.service.AbstractReplicator
Direct Known Subclasses:
NonPersistentReplicator, PersistentReplicator

public abstract class AbstractReplicator extends Object
  • Field Details

    • brokerService

      protected final BrokerService brokerService
    • topicName

      protected final String topicName
    • localCluster

      protected final String localCluster
    • remoteCluster

      protected final String remoteCluster
    • replicationClient

      protected final org.apache.pulsar.client.impl.PulsarClientImpl replicationClient
    • client

      protected final org.apache.pulsar.client.impl.PulsarClientImpl client
    • producer

      protected volatile org.apache.pulsar.client.impl.ProducerImpl producer
    • REPL_PRODUCER_NAME_DELIMITER

      public static final String REPL_PRODUCER_NAME_DELIMITER
      See Also:
    • producerQueueSize

      protected final int producerQueueSize
    • producerBuilder

      protected final org.apache.pulsar.client.api.ProducerBuilder<byte[]> producerBuilder
    • backOff

      protected final org.apache.pulsar.client.impl.Backoff backOff
    • replicatorPrefix

      protected final String replicatorPrefix
    • STATE_UPDATER

  • Constructor Details

    • AbstractReplicator

      public AbstractReplicator(String topicName, String replicatorPrefix, String localCluster, String remoteCluster, BrokerService brokerService, org.apache.pulsar.client.impl.PulsarClientImpl replicationClient) throws org.apache.pulsar.broker.PulsarServerException
      Throws:
      org.apache.pulsar.broker.PulsarServerException
  • Method Details

    • readEntries

      protected abstract void readEntries(org.apache.pulsar.client.api.Producer<byte[]> producer)
    • getReplicatorReadPosition

      protected abstract org.apache.bookkeeper.mledger.Position getReplicatorReadPosition()
    • getNumberOfEntriesInBacklog

      protected abstract long getNumberOfEntriesInBacklog()
    • disableReplicatorRead

      protected abstract void disableReplicatorRead()
    • getRemoteCluster

      public String getRemoteCluster()
    • startProducer

      public void startProducer()
    • closeProducerAsync

      protected CompletableFuture<Void> closeProducerAsync()
    • disconnect

      public CompletableFuture<Void> disconnect()
    • disconnect

      public CompletableFuture<Void> disconnect(boolean failIfHasBacklog)
    • remove

      public CompletableFuture<Void> remove()
    • isWritable

      protected boolean isWritable()
    • getRemoteCluster

      public static String getRemoteCluster(String remoteCursor)
    • getReplicatorName

      public static String getReplicatorName(String replicatorPrefix, String cluster)
    • validatePartitionedTopicAsync

      public static CompletableFuture<Void> validatePartitionedTopicAsync(String topic, BrokerService brokerService)
      Replication can't be started on root-partitioned-topic to avoid producer startup conflict.
       eg:
       if topic : persistent://prop/cluster/ns/my-topic is a partitioned topic with 2 partitions then
       broker explicitly creates replicator producer for: "my-topic-partition-1" and "my-topic-partition-2".
      
       However, if broker tries to start producer with root topic "my-topic" then client-lib internally
       creates individual producers for "my-topic-partition-1" and "my-topic-partition-2" which creates
       conflict with existing
       replicator producers.
       
      Therefore, replicator can't be started on root-partition topic which can internally create multiple partitioned producers.
      Parameters:
      topic -
      brokerService -
    • getState

      public AbstractReplicator.State getState()