/** * Returns the hooks specified in a configuration variable. * * @param hookConfVar The configuration variable specifying a comma separated list of the hook * class names. * @param clazz The super type of the hooks. * @return A list of the hooks cast as the type specified in clazz, in the order * they are listed in the value of hookConfVar * @throws Exception */ private <T extends Hook> List<T> getHooks(ConfVars hookConfVar, Class<T> clazz) throws Exception { try { return HookUtils.getHooks(conf, hookConfVar, clazz); } catch (ClassNotFoundException e) { console.printError(hookConfVar.varname + " Class not found:" + e.getMessage()); throw e; } }
/** * Write out an JSON array of edges. */ private void writeEdges(JsonWriter writer, List<Edge> edges, HiveConf conf) throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException { writer.name("edges"); writer.beginArray(); for (Edge edge: edges) { writer.beginObject(); writer.name("sources"); writer.beginArray(); for (Vertex vertex: edge.sources) { writer.value(vertex.id); } writer.endArray(); writer.name("targets"); writer.beginArray(); for (Vertex vertex: edge.targets) { writer.value(vertex.id); } writer.endArray(); if (edge.expr != null) { writer.name("expression").value(HookUtils.redactLogString(conf, edge.expr)); } writer.name("edgeType").value(edge.type.name()); writer.endObject(); } writer.endArray(); }
private <T extends Hook> List<T> loadHooksFromConf(ConfVars hookConfVar, Class<T> clazz) { try { return HookUtils.readHooksFromConf(conf, hookConfVar); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { String message = "Error loading hooks(" + hookConfVar + "): " + HiveStringUtils.stringifyException(e); throw new RuntimeException(message, e); } }
public static String redactLogString(HiveConf conf, String logString) throws InstantiationException, IllegalAccessException, ClassNotFoundException { String redactedString = logString; if (conf != null && logString != null) { List<Redactor> queryRedactors = getHooks(conf, ConfVars.QUERYREDACTORHOOKS, Redactor.class); for (Redactor redactor : queryRedactors) { redactor.setConf(conf); redactedString = redactor.redactQuery(redactedString); } } return redactedString; } }
@Test public void testRedactLogString() throws Exception { HiveConf conf = new HiveConf(TestHooks.class); String str; HiveConf.setVar(conf, HiveConf.ConfVars.QUERYREDACTORHOOKS, SimpleQueryRedactor.class.getName()); str = HookUtils.redactLogString(null, null); assertEquals(str, null); str = HookUtils.redactLogString(conf, null); assertEquals(str, null); str = HookUtils.redactLogString(conf, "select 'XXX' from t1"); assertEquals(str, "select 'AAA' from t1"); }
private void executeSessionHooks(HiveSession session) throws Exception { List<HiveSessionHook> sessionHooks = HookUtils.readHooksFromConf(hiveConf, HiveConf.ConfVars.HIVE_SERVER2_SESSION_HOOK); for (HiveSessionHook sessionHook : sessionHooks) { sessionHook.run(new HiveSessionHookContextImpl(session)); } }
/** * Returns the hooks specified in a configuration variable. * * @param hookConfVar The configuration variable specifying a comma separated list of the hook * class names. * @param clazz The super type of the hooks. * @return A list of the hooks cast as the type specified in clazz, in the order * they are listed in the value of hookConfVar * @throws Exception */ private <T extends Hook> List<T> getHooks(ConfVars hookConfVar, Class<T> clazz) throws Exception { try { return HookUtils.getHooks(conf, hookConfVar, clazz); } catch (ClassNotFoundException e) { console.printError(hookConfVar.varname + " Class not found:" + e.getMessage()); throw e; } }
queryStr = HookUtils.redactLogString(conf, command); } catch (Exception e) { LOG.warn("WARNING! Query command could not be redacted." + e);
public static String redactLogString(HiveConf conf, String logString) throws InstantiationException, IllegalAccessException, ClassNotFoundException { String redactedString = logString; if (conf != null && logString != null) { List<Redactor> queryRedactors = readHooksFromConf(conf, ConfVars.QUERYREDACTORHOOKS); for (Redactor redactor : queryRedactors) { redactor.setConf(conf); redactedString = redactor.redactQuery(redactedString); } } return redactedString; }
private void executeSessionHooks(HiveSession session) throws Exception { List<HiveSessionHook> sessionHooks = HookUtils.getHooks(hiveConf, HiveConf.ConfVars.HIVE_SERVER2_SESSION_HOOK, HiveSessionHook.class); for (HiveSessionHook sessionHook : sessionHooks) { sessionHook.run(new HiveSessionHookContextImpl(session)); } }
queryStr = HookUtils.redactLogString(conf, command); } catch (Exception e) { LOG.warn("WARNING! Query command could not be redacted." + e);
private void executeSessionHooks(HiveSession session) throws Exception { List<HiveSessionHook> sessionHooks = HookUtils.readHooksFromConf(hiveConf, HiveConf.ConfVars.HIVE_SERVER2_SESSION_HOOK); for (HiveSessionHook sessionHook : sessionHooks) { sessionHook.run(new HiveSessionHookContextImpl(session)); } }
private void executeSessionHooks(HiveSession session) throws Exception { List<HiveSessionHook> sessionHooks = HookUtils.getHooks(hiveConf, HiveConf.ConfVars.HIVE_SERVER2_SESSION_HOOK, HiveSessionHook.class); for (HiveSessionHook sessionHook : sessionHooks) { sessionHook.run(new HiveSessionHookContextImpl(session)); } }
String queryStr = HookUtils.redactLogString(conf, command);
public static String redactLogString(HiveConf conf, String logString) throws InstantiationException, IllegalAccessException, ClassNotFoundException { String redactedString = logString; if (conf != null && logString != null) { List<Redactor> queryRedactors = getHooks(conf, ConfVars.QUERYREDACTORHOOKS, Redactor.class); for (Redactor redactor : queryRedactors) { redactor.setConf(conf); redactedString = redactor.redactQuery(redactedString); } } return redactedString; } }