You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/02/15 06:59:35 UTC

[GitHub] [dolphinscheduler] ronyang1985 commented on a change in pull request #8390: [Fix-8389][Common] Fix oshi compatibility issues cause it fail to boot on m1 mac

ronyang1985 commented on a change in pull request #8390:
URL: https://github.com/apache/dolphinscheduler/pull/8390#discussion_r806499571



##########
File path: dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java
##########
@@ -134,7 +135,11 @@ public static double loadAverage() {
      */
     public static double cpuUsage() {
         CentralProcessor processor = hal.getProcessor();
-        double cpuUsage = processor.getSystemCpuLoad();
+
+        long[] preTicks = processor.getSystemCpuLoadTicks();
+        Util.sleep(1000);

Review comment:
       According to the method annotation, getSystemCpuLoadTicks() method  returns the "recent cpu usage" for the whole system by counting ticks between the user-provided value from a previous call. If not sleeping, it will always return value with 0.0D
   `
       /**
        * Returns the "recent cpu usage" for the whole system by counting ticks from
        * {@link #getSystemCpuLoadTicks()} between the user-provided value from a
        * previous call.
        *
        * @param oldTicks
        *            A tick array from a previous call to
        *            {@link #getSystemCpuLoadTicks()}
        * @return CPU load between 0 and 1 (100%)
        */
       double getSystemCpuLoadBetweenTicks(long[] oldTicks);`




-- 
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-unsubscribe@dolphinscheduler.apache.org

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