Demogorgon314 commented on code in PR #16743:
URL: https://github.com/apache/pulsar/pull/16743#discussion_r928273654


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastResourceUsageWithWeight.java:
##########
@@ -139,7 +139,8 @@ public Optional<String> selectBroker(Set<String> 
candidates, BundleData bundleTo
         final double diffThreshold =
                 
conf.getLoadBalancerAverageResourceUsageDifferenceThresholdPercentage() / 100.0;
         brokerAvgResourceUsageWithWeight.forEach((broker, avgResUsage) -> {
-            if (avgResUsage + diffThreshold <= avgUsage) {
+            if ((avgResUsage + diffThreshold <= avgUsage)
+                    && candidates.contains(broker)) {
                 bestBrokers.add(broker);
             }
         });

Review Comment:
   We can change it to be more simple, right?
   ```java
   for (String broker : candidates) {
       Double avgResUsage = 
brokerAvgResourceUsageWithWeight.getOrDefault(broker, Double.MAX_VALUE);
       if ((avgResUsage + diffThreshold <= avgUsage)) {
           bestBrokers.add(broker);
       }
   }
   ```



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

Reply via email to