kkhatua commented on a change in pull request #1437: DRILL-6702: Disable CPU 
Reporting for non-HotSpot JDKs
URL: https://github.com/apache/drill/pull/1437#discussion_r213418278
 
 

 ##########
 File path: common/src/main/java/org/apache/drill/exec/metrics/CpuGaugeSet.java
 ##########
 @@ -32,13 +32,22 @@
  */
 @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
+    OperatingSystemMXBean tempOSMXBean;
+    try {
+      tempOSMXBean = (OperatingSystemMXBean) 
ManagementFactory.getOperatingSystemMXBean();
+    } catch (ClassCastException cce) {
+      logger.warn("{}. Detected non-Supported JVM [{}]. CPU Metrics in the 
WebUI will not be available!", cce.getMessage(), 
System.getProperty("java.vm.name"));
 
 Review comment:
   @arina-ielchiieva the only message you get is
   ``` java.lang.ClassCastException: 
com.ibm.lang.management.ExtendedOperatingSystem incompatible with 
com.sun.management.OperatingSystemMXBean```
   Not very useful, but you still get the simplified message without stack 
trace. There isn't much value in adding more information than what is already 
there, because the issue only emerged when JDBC drivers were being built using 
the IBM JDK, something that a regular user will not face. (my testing showed 
that an OracleJDK compiled class ran without issue for an IBM JDK Runtime).
   
   I'll apply Vlad's suggestion & squash the commits.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to