michaeljmarshall commented on code in PR #20567:
URL: https://github.com/apache/pulsar/pull/20567#discussion_r1235925376
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java:
##########
@@ -158,6 +163,31 @@ public synchronized void startProducer() {
}
+ protected void checkTopicActiveAndRetryStartProducer() {
+ isLocalTopicActive().thenAccept(isTopicActive -> {
+ if (isTopicActive) {
+ startProducer();
+ }
+ }).exceptionally(ex -> {
+ log.warn("[{}] Stop retry to create producer due to topic load
fail. Replicator state: {}", replicatorId,
+ STATE_UPDATER.get(this), ex);
+ return null;
+ });
+ }
+
+ protected CompletableFuture<Boolean> isLocalTopicActive() {
+ CompletableFuture<Optional<Topic>> topicFuture =
brokerService.getTopics().get(localTopicName);
+ if (topicFuture == null){
+ return CompletableFuture.completedFuture(false);
+ }
+ return topicFuture.thenApplyAsync(optional -> {
+ if (optional.isEmpty()) {
+ return false;
+ }
+ return optional.get() == localTopic;
Review Comment:
I am not sure that we want to use reference equality here. I would think we
always want to shut down the `AbastractReplicator` class and let it get
recreated when a topic is closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]