Repository: hive Updated Branches: refs/heads/master 170637386 -> 3491c3973
HIVE-15889: LLAP: Some tasks still run after hive cli is shutdown (Rajesh Balamohan, 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/3491c397 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/3491c397 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/3491c397 Branch: refs/heads/master Commit: 3491c3973a83d9323345dbf84190194846522e82 Parents: 1706373 Author: Rajesh Balamohan <[email protected]> Authored: Tue Feb 14 09:02:08 2017 +0530 Committer: Rajesh Balamohan <[email protected]> Committed: Tue Feb 14 09:02:08 2017 +0530 ---------------------------------------------------------------------- .../hive/ql/exec/tez/TezJobExecHelper.java | 29 ++++++++++++++++---- .../ql/exec/tez/monitoring/TezJobMonitor.java | 5 +++- 2 files changed, 27 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/3491c397/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezJobExecHelper.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezJobExecHelper.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezJobExecHelper.java index a544b93..caeef40 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezJobExecHelper.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezJobExecHelper.java @@ -32,19 +32,36 @@ public class TezJobExecHelper { private static final Logger LOG = LoggerFactory.getLogger(TezJobExecHelper.class.getName()); - public static void killRunningJobs() { + private static final Method KILL_RUNNING_TEZ_JOBS; + + static { + Method method = null; try { Class.forName("org.apache.tez.dag.api.DAG"); // we have tez installed ClassLoader classLoader = TezJobExecHelper.class.getClassLoader(); - Method method = classLoader.loadClass("org.apache.hadoop.hive.ql.exec.tez.monitoring.TezJobMonitor") - .getMethod("killRunningJobs"); - method.invoke(null, null); + + method = classLoader + .loadClass("org.apache.hadoop.hive.ql.exec.tez.monitoring.TezJobMonitor") + .getDeclaredMethod("killRunningJobs"); + method.setAccessible(true); + } catch (Exception e) { + LOG.error("Error getting tez method", e); } - catch (Exception e) { + KILL_RUNNING_TEZ_JOBS = method; + } + + public static void killRunningJobs() { + try { + if (KILL_RUNNING_TEZ_JOBS != null) { + KILL_RUNNING_TEZ_JOBS.invoke(null, null); + } else { + LOG.warn("Unable to find tez method for killing jobs"); + } + } catch (Exception e) { // It is not available do nothing - LOG.debug("Could not stop tez dags: ", e); + LOG.error("Could not stop tez dags: ", e); } } } http://git-wip-us.apache.org/repos/asf/hive/blob/3491c397/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/monitoring/TezJobMonitor.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/monitoring/TezJobMonitor.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/monitoring/TezJobMonitor.java index 1e54f6e..c0a068d 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/monitoring/TezJobMonitor.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/monitoring/TezJobMonitor.java @@ -300,8 +300,11 @@ public class TezJobMonitor { /** * killRunningJobs tries to terminate execution of all * currently running tez queries. No guarantees, best effort only. + * + * {@link org.apache.hadoop.hive.ql.exec.tez.TezJobExecHelper#killRunningJobs()} makes use of + * this method via reflection. */ - private static void killRunningJobs() { + public static void killRunningJobs() { synchronized (shutdownList) { for (DAGClient c : shutdownList) { try {
