private static void invokeGeneralHook(List<ExecuteWithHookContext> hooks, String prefix, HookContext hookContext) throws HiveException { if (hooks.isEmpty()) { return; } try { PerfLogger perfLogger = SessionState.getPerfLogger(); for (ExecuteWithHookContext hook : hooks) { perfLogger.PerfLogBegin(CLASS_NAME, prefix + hook.getClass().getName()); hook.run(hookContext); perfLogger.PerfLogEnd(CLASS_NAME, prefix + hook.getClass().getName()); } } catch (HiveException e) { throw e; } catch (Exception e) { throw new HiveException("Error while invoking " + prefix + " hooks: " + HiveStringUtils.stringifyException(e), e); } }
private void invokeFailureHooks(PerfLogger perfLogger, HookContext hookContext, String errorMessage, Throwable exception) throws Exception { hookContext.setHookType(HookContext.HookType.ON_FAILURE_HOOK); hookContext.setErrorMessage(errorMessage); hookContext.setException(exception); // 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()); } }
@Override public void run(final HookContext hookContext) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("==> HiveHook.run({})", hookContext); } try { activatePluginClassLoader(); hiveHookImpl.run(hookContext); } finally { deactivatePluginClassLoader(); } if (LOG.isDebugEnabled()) { LOG.debug("<== HiveHook.run({})", hookContext); } }
((ExecuteWithHookContext) peh).run(hookContext); } else if (peh instanceof PreExecute) { ((PreExecute) peh).run(SessionState.get(), plan.getInputs(), plan.getOutputs(), ((ExecuteWithHookContext) peh).run(hookContext); } else if (peh instanceof PostExecute) { ((PostExecute) peh).run(SessionState.get(), plan.getInputs(), plan.getOutputs(),
perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.PRE_HOOK + peh.getClass().getName()); ((ExecuteWithHookContext) peh).run(hookContext); perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.FAILURE_HOOK + ofh.getClass().getName()); ((ExecuteWithHookContext) ofh).run(hookContext); perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.POST_HOOK + peh.getClass().getName()); ((ExecuteWithHookContext) peh).run(hookContext);