heesung-sn commented on code in PR #16832:
URL: https://github.com/apache/pulsar/pull/16832#discussion_r1178536739


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LinuxInfoUtils.java:
##########
@@ -98,11 +138,14 @@ public static double getTotalCpuLimit(boolean 
isCGroupsEnabled) {
      * Get CGroup cpu usage.
      * @return Cpu usage
      */
-    public static double getCpuUsageForCGroup() {
+    public static long getCpuUsageForCGroup() {
         try {
+            if (metrics != null && getCpuUsageMethod != null) {
+                return (long) getCpuUsageMethod.invoke(metrics);

Review Comment:
   For backward compatibility, don't we need to multiply the limit in 
calculateBrokerHostUsage?
   ```
   public void calculateBrokerHostUsage() {
   ... 
          double totalCpuLimit = getTotalCpuLimit(isCGroupsEnabled);
           if (isCGroupsEnabled && metrics != null && getCpuUsageMethod != 
null) {
               // cgroup cpuUsage is already scaled, [0.0, 1.0]
               usage.setCpu(new ResourceUsage(cpuUsage * totalCpuLimit, 
totalCpuLimit));
           } else {
               usage.setCpu(new ResourceUsage(cpuUsage, totalCpuLimit));
           }
           
   ```



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to