You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/02/10 08:30:34 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #9393: Fix testBrokerSelectionForAntiAffinityGroup by increasing OverloadedThreshold

eolivelli commented on a change in pull request #9393:
URL: https://github.com/apache/pulsar/pull/9393#discussion_r573533094



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/GenericBrokerHostUsageImpl.java
##########
@@ -62,8 +67,10 @@ public SystemResourceUsage getBrokerHostUsage() {
     }
 
     private void checkCpuLoad() {
-        cpuUsageSum += systemBean.getSystemCpuLoad();
-        cpuUsageCount++;
+        synchronized (this) {

Review comment:
       nit: what about moving the `synchronized` keyword in the method declaration ?

##########
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:
       nit: what about moving the `synchronized` keyword in the method declaration ?




----------------------------------------------------------------
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:
users@infra.apache.org