315157973 commented on a change in pull request #9443:
URL: https://github.com/apache/pulsar/pull/9443#discussion_r569561747



##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/LoadBalancerTest.java
##########
@@ -176,23 +176,30 @@ void shutdown() throws Exception {
         bkEnsemble.stop();
     }
 
-    private LeaderBroker loopUntilLeaderChanges(LeaderElectionService les, 
LeaderBroker oldLeader,
-            LeaderBroker newLeader) throws InterruptedException {
+    private void loopUntilLeaderChangesForAllBroker(List<PulsarService> 
activePulsars, LeaderBroker oldLeader)
+            throws InterruptedException {
         int loopCount = 0;
+        boolean settled;
 
         while (loopCount < MAX_RETRIES) {
             Thread.sleep(1000);
-            // Check if the new leader is elected. If yes, break without 
incrementing the loopCount
-            newLeader = les.getCurrentLeader().get();
-            if (newLeader.equals(oldLeader) == false) {
+            settled = true;
+            // Check if the all active pulsar see a new leader
+            for (PulsarService pulsar : activePulsars) {
+                Optional<LeaderBroker> leader = 
pulsar.getLeaderElectionService().readCurrentLeader().join();
+                if (leader.isPresent() && leader.get().equals(oldLeader)) {

Review comment:
       Good job ,I have a question:
   Since there will be a single follower who cannot see the new leader until 
timeout, why traversing all the followers can solve this problem?
   The current logic is: as long as there is no old leader in all followers, it 
will be successful, but there will still be cases where empty is returned.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to