You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jx...@apache.org on 2016/04/16 02:36:15 UTC
hive git commit: HIVE-13501: Invoke failure hooks if query fails on
exception (Jimmy, reviewed by Szehon)
Repository: hive
Updated Branches:
refs/heads/master 88cea1c21 -> ff6ddfb3c
HIVE-13501: Invoke failure hooks if query fails on exception (Jimmy, reviewed by Szehon)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/ff6ddfb3
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/ff6ddfb3
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/ff6ddfb3
Branch: refs/heads/master
Commit: ff6ddfb3cf4640f65ebd184e89e587c94fa0131e
Parents: 88cea1c
Author: Jimmy Xiang <jx...@apache.org>
Authored: Tue Apr 12 14:26:43 2016 -0700
Committer: Jimmy Xiang <jx...@apache.org>
Committed: Fri Apr 15 17:29:10 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/hadoop/hive/ql/Driver.java | 39 ++++++++++++++------
1 file changed, 27 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/ff6ddfb3/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
index 92c2c76..6062ac0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
@@ -98,11 +98,11 @@ import org.apache.hadoop.hive.ql.processors.CommandProcessor;
import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse;
import org.apache.hadoop.hive.ql.security.authorization.AuthorizationUtils;
import org.apache.hadoop.hive.ql.security.authorization.HiveAuthorizationProvider;
-import org.apache.hadoop.hive.ql.security.authorization.plugin.QueryContext;
import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject;
import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject.HivePrivObjectActionType;
import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject.HivePrivilegeObjectType;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.QueryContext;
import org.apache.hadoop.hive.ql.session.OperationLog;
import org.apache.hadoop.hive.ql.session.OperationLog.LoggingLevel;
import org.apache.hadoop.hive.ql.session.SessionState;
@@ -1505,6 +1505,8 @@ public class Driver implements CommandProcessor {
maxthreads = HiveConf.getIntVar(conf, HiveConf.ConfVars.EXECPARALLETHREADNUMBER);
+ HookContext hookContext = null;
+
try {
LOG.info("Executing command(queryId=" + queryId + "): " + queryStr);
// compile and execute can get called from different threads in case of HS2
@@ -1521,7 +1523,7 @@ public class Driver implements CommandProcessor {
resStream = null;
SessionState ss = SessionState.get();
- HookContext hookContext = new HookContext(plan, conf, ctx.getPathToCS(), ss.getUserName(),
+ hookContext = new HookContext(plan, conf, ctx.getPathToCS(), ss.getUserName(),
ss.getUserIpAddress(), operationId);
hookContext.setHookType(HookContext.HookType.PRE_EXEC_HOOK);
@@ -1632,16 +1634,7 @@ public class Driver implements CommandProcessor {
} else {
setErrorMsgAndDetail(exitVal, result.getTaskError(), tsk);
- hookContext.setHookType(HookContext.HookType.ON_FAILURE_HOOK);
- hookContext.setErrorMessage(errorMessage);
- // Get all the failure execution hooks and execute them.
- for (Hook ofh : getHooks(HiveConf.ConfVars.ONFAILUREHOOKS)) {
- perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.FAILURE_HOOK + ofh.getClass().getName());
-
- ((ExecuteWithHookContext) ofh).run(hookContext);
-
- perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.FAILURE_HOOK + ofh.getClass().getName());
- }
+ invokeFailureHooks(perfLogger, hookContext);
SQLState = "08S01";
console.printError(errorMessage);
driverCxt.shutdown();
@@ -1677,6 +1670,7 @@ public class Driver implements CommandProcessor {
if (driverCxt.isShutdown()) {
SQLState = "HY008";
errorMessage = "FAILED: Operation cancelled";
+ invokeFailureHooks(perfLogger, hookContext);
console.printError(errorMessage);
return 1000;
}
@@ -1731,6 +1725,13 @@ public class Driver implements CommandProcessor {
}
// TODO: do better with handling types of Exception here
errorMessage = "FAILED: Hive Internal Error: " + Utilities.getNameMessage(e);
+ if (hookContext != null) {
+ try {
+ invokeFailureHooks(perfLogger, hookContext);
+ } catch (Exception t) {
+ LOG.warn("Failed to invoke failure hook", t);
+ }
+ }
SQLState = "08S01";
downstreamError = e;
console.printError(errorMessage + "\n"
@@ -1804,6 +1805,20 @@ public class Driver implements CommandProcessor {
}
}
}
+
+ private void invokeFailureHooks(PerfLogger perfLogger, HookContext hookContext) throws Exception {
+ hookContext.setHookType(HookContext.HookType.ON_FAILURE_HOOK);
+ hookContext.setErrorMessage(errorMessage);
+ // Get all the failure execution hooks and execute them.
+ for (Hook ofh : getHooks(HiveConf.ConfVars.ONFAILUREHOOKS)) {
+ perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.FAILURE_HOOK + ofh.getClass().getName());
+
+ ((ExecuteWithHookContext) ofh).run(hookContext);
+
+ perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.FAILURE_HOOK + ofh.getClass().getName());
+ }
+ }
+
/**
* Launches a new task
*