lhotari commented on code in PR #17254:
URL: https://github.com/apache/pulsar/pull/17254#discussion_r954729783
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java:
##########
@@ -644,6 +646,25 @@ private CompletableFuture<Optional<CandidateBrokerResult>>
getCandidateBrokerRes
}
+ private CompletableFuture<Optional<LeaderBroker>>
getOrWaitForLeader(AtomicInteger retries) {
+ return pulsar.getLeaderElectionService().readCurrentLeader()
+ .handle((leaderBroker, t) -> {
+ CompletableFuture<Optional<LeaderBroker>> retval;
+ if ((t != null || !leaderBroker.isPresent()) &&
retries.getAndIncrement() < 3) {
+ // retry after a delay of 5 seconds
+ retval =
+ CompletableFuture.supplyAsync(() -> null,
+
CompletableFuture.delayedExecutor(5, SECONDS))
Review Comment:
it's not really a problem to use the system's pool for delayed executor.
However, delayed executor isn't available in Java 8 and using this will make
backporting harder. I'll use Pulsar's existing scheduler for this purpose so
that backporting will be easier.
--
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]