aboutsummaryrefslogtreecommitdiff
path: root/common/src/main
diff options
context:
space:
mode:
authorKunal Khatua <kkhatua@users.noreply.github.com>2018-09-04 17:11:10 -0700
committerGitHub <noreply@github.com>2018-09-04 17:11:10 -0700
commitcc75188d0ce70f102786f69aa070255dd406ff3c (patch)
tree985947689e606d5d56a04acc06426937a690a516 /common/src/main
parent14ad83883742503ea791f1c6cd3c419322527b98 (diff)
DRILL-6702: Disable CPU Reporting for non-HotSpot JDKs
When running Drill on the IBM JDK (J9), the webUI throws an ClassCastException : Caused by: java.lang.ClassCastException: com.ibm.lang.management.ExtendedOperatingSystem incompatible with com.sun.management.OperatingSystemMXBean This PR simply disables that, since Drill should ideally be recompiled with these alternative JDKs.
Diffstat (limited to 'common/src/main')
-rw-r--r--common/src/main/java/org/apache/drill/exec/metrics/CpuGaugeSet.java21
1 files changed, 16 insertions, 5 deletions
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 a652e3c50..f1ca2ae76 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 @@ import com.sun.management.OperatingSystemMXBean;
*/
@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 class CpuGaugeSet implements MetricSet {
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 @@ final class OperatingSystemLoad implements Gauge<Double> {
@Override
public Double getValue() {
- return osMXBean.getSystemLoadAverage();
+ return (osMXBean != null) ? osMXBean.getSystemLoadAverage() : null;
}
}
@@ -80,7 +91,7 @@ final class DrillbitProcessLoad implements Gauge<Double> {
@Override
public Double getValue() {
- return osMXBean.getProcessCpuLoad();
+ return (osMXBean != null) ? osMXBean.getProcessCpuLoad() : null;
}
}