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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]