arunramani commented on a change in pull request #11783:
URL: https://github.com/apache/druid/pull/11783#discussion_r725114303



##########
File path: 
core/src/main/java/org/apache/druid/java/util/metrics/CgroupCpuMonitor.java
##########
@@ -65,12 +65,23 @@ public boolean doMonitor(ServiceEmitter emitter)
     emitter.emit(builder.build("cgroup/cpu/shares", cpuSnapshot.getShares()));
     emitter.emit(builder.build(
         "cgroup/cpu/cores_quota",
-        cpuSnapshot.getPeriodUs() == 0
-        ? 0
-        : ((double) cpuSnapshot.getQuotaUs()
-          ) / cpuSnapshot.getPeriodUs()
+        computeProcessorQuota(cpuSnapshot.getQuotaUs(), 
cpuSnapshot.getPeriodUs())
     ));
 
     return true;
   }
+
+  /**
+   * Calculates the total cores allocated through quotas.
+   *
+   * @param quotaUs  the cgroup quota value.
+   * @param periodUs the cgroup period value.
+   * @return the calculated processor quota, -1 if no quota or period set.
+   */
+  public static double computeProcessorQuota(long quotaUs, long periodUs)
+  {
+    return quotaUs < 0 || periodUs == 0

Review comment:
       A single negative value should be enough. The idea is to indicate that 
there's no quota.




-- 
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]

Reply via email to