kfaraz commented on code in PR #13197: URL: https://github.com/apache/druid/pull/13197#discussion_r993462870
########## server/src/main/java/org/apache/druid/server/coordinator/CostBalancerStrategy.java: ########## @@ -49,6 +50,14 @@ public class CostBalancerStrategy implements BalancerStrategy private static final double MILLIS_IN_HOUR = 3_600_000.0; private static final double MILLIS_FACTOR = MILLIS_IN_HOUR / LAMBDA; + /** + * Comparator that prioritizes servers by cost. Cheaper servers come before + * costlier servers. Servers with the same cost may appear in a random order. + */ + private static final Comparator<Pair<Double, ServerHolder>> CHEAPEST_SERVERS_FIRST + = Comparator.<Pair<Double, ServerHolder>, Double>comparing(pair -> pair.lhs) + .thenComparing(pair -> ThreadLocalRandom.current().nextInt()); Review Comment: Sure, that would work too. This PR does not make any modifications to strategies, so it has not been included here. The only modification done here is reduction in the number of calls to strategy. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
