315157973 commented on code in PR #19560:
URL: https://github.com/apache/pulsar/pull/19560#discussion_r1118194553
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java:
##########
@@ -233,5 +237,23 @@ private Pair<Boolean, String> getMaxUsageBroker(
}
return Pair.of(hasBrokerBelowLowerBound, maxUsageBrokerName);
}
+ @Override
+ public void onBrokerChange(Set<String> newBrokers) {
+ synchronized (activeBrokers) {
+ activeBrokers.clear();
+ activeBrokers.addAll(newBrokers);
+ }
Review Comment:
If we modify `brokerAvgResourceUsage` directly, the entire
`ThresholdShedder` needs to be locked every time, because there are 2 threads
modify `brokerAvgResourceUsage` at the same time.
And now we don't need to lock every time, only when broker changes
--
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]