You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by je...@apache.org on 2018/10/10 05:48:30 UTC

[incubator-dubbo] branch master updated: fix #1641, support get system load on windows (#2631)

This is an automated email from the ASF dual-hosted git repository.

jerrick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new d738318  fix #1641, support get system load on windows (#2631)
d738318 is described below

commit d73831895bc8dc9e85d6818571d6fa17a27ba404
Author: Jerrick Zhu <di...@gmail.com>
AuthorDate: Wed Oct 10 13:48:23 2018 +0800

    fix #1641, support get system load on windows (#2631)
---
 .../org/apache/dubbo/common/status/support/LoadStatusChecker.java    | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/status/support/LoadStatusChecker.java b/dubbo-common/src/main/java/org/apache/dubbo/common/status/support/LoadStatusChecker.java
index 7f91255..c5e2204 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/status/support/LoadStatusChecker.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/status/support/LoadStatusChecker.java
@@ -37,6 +37,11 @@ public class LoadStatusChecker implements StatusChecker {
         try {
             Method method = OperatingSystemMXBean.class.getMethod("getSystemLoadAverage", new Class<?>[0]);
             load = (Double) method.invoke(operatingSystemMXBean, new Object[0]);
+            if (load == -1) {
+                com.sun.management.OperatingSystemMXBean bean =
+                        (com.sun.management.OperatingSystemMXBean) operatingSystemMXBean;
+                load = bean.getSystemCpuLoad();
+            }
         } catch (Throwable e) {
             load = -1;
         }