Package org.apache.pulsar.broker.service
Class AbstractReplicator
java.lang.Object
org.apache.pulsar.broker.service.AbstractReplicator
- All Implemented Interfaces:
Replicator
- Direct Known Subclasses:
NonPersistentReplicator,PersistentReplicator
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.pulsar.common.util.Backoffprotected final BrokerServiceprotected final PulsarClientImplprotected final Stringprotected final Topicprotected final Stringprotected ProducerImplprotected final org.apache.pulsar.client.api.ProducerBuilder<byte[]>protected final intprotected final Stringprotected final Stringstatic final Stringprotected final PulsarClientImplprotected Stringprotected final Stringprotected AbstractReplicator.Stateprotected static final AtomicReferenceFieldUpdater<AbstractReplicator,AbstractReplicator.State> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractReplicator(String localCluster, Topic localTopic, String remoteCluster, String remoteTopicName, String replicatorPrefix, BrokerService brokerService, PulsarClientImpl replicationClient) -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletableFuture<Void>closeProducerAsync(boolean closeTheStartingProducer) This method only be used byPersistentTopic.checkGC()now.protected org.apache.commons.lang3.tuple.ImmutablePair<Boolean,AbstractReplicator.State> compareSetAndGetState(AbstractReplicator.State expect, AbstractReplicator.State update) protected voidThe producer is disconnecting, delay to start the producer.protected abstract voiddisconnect(boolean failIfHasBacklog, boolean closeTheStartingProducer) This method only be used byPersistentTopic.checkGC()now.protected CompletableFuture<Void>doCloseProducerAsync(org.apache.pulsar.client.api.Producer<byte[]> producer, Runnable actionAfterClosed) protected voidio.opentelemetry.api.common.Attributesabstract longprotected abstract Stringstatic StringgetRemoteCluster(String remoteCursor) longstatic StringgetReplicatorName(String replicatorPrefix, String cluster) protected abstract PositiongetState()booleanprotected CompletableFuture<Boolean>booleanprotected booleanprotected CompletableFuture<Void>remove()protected voidscheduleCheckTopicActiveAndStartProducer(long waitTimeMs) protected abstract voidsetProducerAndTriggerReadEntries(org.apache.pulsar.client.api.Producer<byte[]> producer) voidprotected booleanstatic CompletableFuture<Void>validatePartitionedTopicAsync(String topic, BrokerService brokerService) Replication can't be started on root-partitioned-topic to avoid producer startup conflict.Methods 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.Replicator
computeStats, getLocalTopic, getRateLimiter, getStats, initializeDispatchRateLimiterIfNeeded, updateRateLimiter, updateRates
-
Field Details
-
brokerService
-
localTopicName
-
localCluster
-
remoteTopicName
-
remoteCluster
-
replicationClient
-
client
-
replicatorId
-
localTopic
-
producer
-
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.common.util.Backoff backOff -
replicatorPrefix
-
STATE_UPDATER
protected static final AtomicReferenceFieldUpdater<AbstractReplicator,AbstractReplicator.State> STATE_UPDATER -
state
-
-
Constructor Details
-
AbstractReplicator
public AbstractReplicator(String localCluster, Topic localTopic, String remoteCluster, String remoteTopicName, String replicatorPrefix, BrokerService brokerService, PulsarClientImpl replicationClient) throws PulsarServerException - Throws:
PulsarServerException
-
-
Method Details
-
getProducerName
-
setProducerAndTriggerReadEntries
protected abstract void setProducerAndTriggerReadEntries(org.apache.pulsar.client.api.Producer<byte[]> producer) -
getReplicatorReadPosition
-
getNumberOfEntriesInBacklog
public abstract long getNumberOfEntriesInBacklog()- Specified by:
getNumberOfEntriesInBacklogin interfaceReplicator
-
disableReplicatorRead
protected abstract void disableReplicatorRead() -
isConnected
public boolean isConnected()- Specified by:
isConnectedin interfaceReplicator
-
getReplicationDelayMs
public long getReplicationDelayMs() -
getRemoteCluster
- Specified by:
getRemoteClusterin interfaceReplicator
-
prepareCreateProducer
-
startProducer
public void startProducer()- Specified by:
startProducerin interfaceReplicator
-
delayStartProducerAfterDisconnected
protected void delayStartProducerAfterDisconnected()The producer is disconnecting, delay to start the producer. If we start a producer immediately, we will get a conflict producer(same name producer) registered error. -
scheduleCheckTopicActiveAndStartProducer
protected void scheduleCheckTopicActiveAndStartProducer(long waitTimeMs) -
isLocalTopicActive
-
disconnect
public CompletableFuture<Void> disconnect(boolean failIfHasBacklog, boolean closeTheStartingProducer) This method only be used byPersistentTopic.checkGC()now.- Specified by:
disconnectin interfaceReplicator
-
closeProducerAsync
This method only be used byPersistentTopic.checkGC()now. -
doCloseProducerAsync
protected CompletableFuture<Void> doCloseProducerAsync(org.apache.pulsar.client.api.Producer<byte[]> producer, Runnable actionAfterClosed) -
terminate
- Specified by:
terminatein interfaceReplicator
-
doReleaseResources
protected void doReleaseResources() -
tryChangeStatusToTerminating
protected boolean tryChangeStatusToTerminating() -
remove
-
isWritable
protected boolean isWritable() -
getRemoteCluster
-
getReplicatorName
-
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
-
compareSetAndGetState
protected org.apache.commons.lang3.tuple.ImmutablePair<Boolean,AbstractReplicator.State> compareSetAndGetState(AbstractReplicator.State expect, AbstractReplicator.State update) -
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceReplicator
-
getAttributes
public io.opentelemetry.api.common.Attributes getAttributes()
-