drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] kkhatua closed pull request #1437: DRILL-6702: Disable CPU Reporting for non-HotSpot JDKs
Date Wed, 05 Sep 2018 00:11:12 GMT
kkhatua closed pull request #1437: DRILL-6702: Disable CPU Reporting for non-HotSpot JDKs
URL: https://github.com/apache/drill/pull/1437
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/common/src/main/java/org/apache/drill/exec/metrics/CpuGaugeSet.java b/common/src/main/java/org/apache/drill/exec/metrics/CpuGaugeSet.java
index a652e3c50e6..f1ca2ae7642 100644
--- a/common/src/main/java/org/apache/drill/exec/metrics/CpuGaugeSet.java
+++ b/common/src/main/java/org/apache/drill/exec/metrics/CpuGaugeSet.java
@@ -32,13 +32,15 @@
  */
 @SuppressWarnings("restriction")
 public class CpuGaugeSet implements MetricSet {
+  private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CpuGaugeSet.class);
 
-  private OperatingSystemMXBean osMXBean;
-  private RuntimeMXBean rtMXBean;
+  private final OperatingSystemMXBean osMXBean;
+  private final RuntimeMXBean rtMXBean;
 
   public CpuGaugeSet() {
-    this.osMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
     this.rtMXBean = ManagementFactory.getRuntimeMXBean();
+    //DRILL-6702: Instead of worrying about compiling with IBM JDK, for now, we shall provide
no CPU metrics for non-HotSpot JVMs
+    this.osMXBean = getOSMXBeanForCpuMetrics();
   }
 
   @Override
@@ -49,6 +51,15 @@ public CpuGaugeSet() {
     metric.put("drillbit.uptime", new DrillbitUptime(rtMXBean));
     return metric;
   }
+
+  private static OperatingSystemMXBean getOSMXBeanForCpuMetrics() {
+    try {
+      return (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
+    } catch (ClassCastException ex) {
+      logger.warn("{}. Detected non-Supported JVM [{}]. CPU Metrics in the WebUI will not
be available!", ex.getMessage(), System.getProperty("java.vm.name"));
+    }
+    return null;
+  }
 }
 
 /**
@@ -63,7 +74,7 @@ public OperatingSystemLoad(OperatingSystemMXBean osBean) {
 
   @Override
   public Double getValue() {
-    return osMXBean.getSystemLoadAverage();
+    return (osMXBean != null) ? osMXBean.getSystemLoadAverage() : null;
   }
 
 }
@@ -80,7 +91,7 @@ public DrillbitProcessLoad(OperatingSystemMXBean osBean) {
 
   @Override
   public Double getValue() {
-    return osMXBean.getProcessCpuLoad();
+    return (osMXBean != null) ? osMXBean.getProcessCpuLoad() : null;
   }
 
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

Mime
View raw message