michaeljmarshall commented on a change in pull request #9393:
URL: https://github.com/apache/pulsar/pull/9393#discussion_r573856593
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/GenericBrokerHostUsageImpl.java
##########
@@ -85,10 +92,12 @@ private double getTotalCpuLimit() {
}
private double getTotalCpuUsage() {
- double cpuUsage = cpuUsageSum / cpuUsageCount;
- cpuUsageSum = 0d;
- cpuUsageCount = 0;
- return cpuUsage;
+ synchronized (this) {
Review comment:
I did this, and I also moved the check for `cpuUsageCount` being zero
into this method. It makes more sense to me in the synchronized method, and it
will ensure that if any other methods end up calling this one, there isn't a
chance of accidentally dividing by 0.
----------------------------------------------------------------
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]