You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "Technoboy- (via GitHub)" <gi...@apache.org> on 2023/06/13 06:53:16 UTC

[GitHub] [pulsar] Technoboy- commented on a diff in pull request #20567: [fix][broker] release orphan replicator after topic closed

Technoboy- commented on code in PR #20567:
URL: https://github.com/apache/pulsar/pull/20567#discussion_r1227615481


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java:
##########
@@ -158,6 +163,32 @@ public synchronized void startProducer() {
 
     }
 
+    protected void checkTopicActiveAndRetryStartProducer() {
+        isLocalTopicActive().thenApply(isTopicActive -> {
+            if (isTopicActive) {
+                startProducer();
+            }
+            return null;
+        }).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;
+        }, brokerService.executor());

Review Comment:
   Seems no need to use `thenApplyAsync`



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org