hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject hive git commit: HIVE-13610 : Hive exec module won't compile with IBM JDK (Pan Yuxuan, reviewed by Sergey Shelukhin)
Date Tue, 30 Aug 2016 19:28:48 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-1 78b17ae66 -> 0d794eb95


HIVE-13610 : Hive exec module won't compile with IBM JDK (Pan Yuxuan, reviewed by Sergey Shelukhin)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/0d794eb9
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0d794eb9
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0d794eb9

Branch: refs/heads/branch-1
Commit: 0d794eb9564055e0f3990dbda767163bd9a23d2d
Parents: 78b17ae
Author: Sergey Shelukhin <sershe@apache.org>
Authored: Tue Aug 30 12:21:04 2016 -0700
Committer: Sergey Shelukhin <sershe@apache.org>
Committed: Tue Aug 30 12:28:17 2016 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hive/ql/debug/Utils.java  | 56 +++++++++++++++-----
 1 file changed, 43 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/0d794eb9/ql/src/java/org/apache/hadoop/hive/ql/debug/Utils.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/debug/Utils.java b/ql/src/java/org/apache/hadoop/hive/ql/debug/Utils.java
index 439b46a..5d98b82 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/debug/Utils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/debug/Utils.java
@@ -19,21 +19,46 @@
 package org.apache.hadoop.hive.ql.debug;
 
 import java.io.File;
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.lang.management.ManagementFactory;
+import java.lang.reflect.Method;
 
 import javax.management.MBeanServer;
 
 import org.apache.commons.lang.StringUtils;
-
-import com.sun.management.HotSpotDiagnosticMXBean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Debug utility methods for Hive.
  */
 public class Utils {
+  private static final Logger LOG = LoggerFactory.getLogger(Utils.class.getName());
   private static final String HOTSPOT_BEAN_NAME = "com.sun.management:type=HotSpotDiagnostic";
-  private static volatile HotSpotDiagnosticMXBean hotspotMBean;
+  private static volatile Object hotspotMBean;
+  private static final Method DUMP_HEAP_METHOD;
+  private static final Class HOTSPOT_MXBEAN_CLASS;
+
+  static {
+    Class clazz;
+    Method method;
+    try{
+      clazz = Class.forName("com.sun.management.HotSpotDiagnosticMXBean");
+      method = clazz.getMethod("dumpHeap", String.class, Boolean.class);
+    } catch (ClassNotFoundException ce) {
+      LOG.error("com.sun.management.HotSpotDiagnosticMXBean is not supported.", ce);
+      throw new RuntimeException(ce);
+    } catch (NoSuchMethodException ne) {
+      LOG.error("Failed to inject operation dumpHeap.", ne);
+      throw new RuntimeException(ne);
+    } catch (Exception e){
+      LOG.error(e.getMessage());
+      throw new RuntimeException(e);
+    }
+    HOTSPOT_MXBEAN_CLASS = clazz;
+    DUMP_HEAP_METHOD = method;
+  }
 
   /**
    * Dumps process heap to a file in temp directoty.
@@ -62,23 +87,28 @@ public class Utils {
       try {
         MBeanServer server = ManagementFactory.getPlatformMBeanServer();
         hotspotMBean = ManagementFactory.newPlatformMXBeanProxy(server,
-            HOTSPOT_BEAN_NAME, HotSpotDiagnosticMXBean.class);
-      } catch (RuntimeException re) {
-          throw re;
-      } catch (Exception exp) {
-          throw new RuntimeException(exp);
+            HOTSPOT_BEAN_NAME, HOTSPOT_MXBEAN_CLASS);
+      } catch (IOException e) {
+        LOG.error(e.getMessage());
+        throw new RuntimeException(e);
       }
     }
-    try {
-        hotspotMBean.dumpHeap(fileName, live);
-    } catch (RuntimeException re) {
+    if(DUMP_HEAP_METHOD != null) {
+      try {
+        DUMP_HEAP_METHOD.invoke(hotspotMBean, new Object[]{fileName, Boolean.valueOf(live)});
+      } catch (RuntimeException re) {
+        LOG.error(re.getMessage());
         throw re;
-    } catch (Exception exp) {
+      } catch (Exception exp) {
+        LOG.error(exp.getMessage());
         throw new RuntimeException(exp);
+      }
+    } else {
+      LOG.error("Cannot find method dumpHeap() in com.sun.management.HotSpotDiagnosticMXBean.");
     }
   }
 
-  /** 
+  /**
    * Outputs some bytes as hex w/printable characters prints.
    * Helpful debug method; c/p from HBase Bytes.
    * @param b Bytes.


Mime
View raw message