use of org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto in project hive by apache.
the class TestHiveProtoLoggingHook method testPreEventLog.
@Test
public void testPreEventLog() throws Exception {
context.setHookType(HookType.PRE_EXEC_HOOK);
EventLogger evtLogger = new EventLogger(conf, SystemClock.getInstance());
evtLogger.handle(context);
evtLogger.shutdown();
HiveHookEventProto event = loadEvent(conf, tmpFolder);
Assert.assertEquals(EventType.QUERY_SUBMITTED.name(), event.getEventType());
Assert.assertEquals(1234L, event.getTimestamp());
Assert.assertEquals(System.getProperty("user.name"), event.getUser());
Assert.assertEquals("test_user", event.getRequestUser());
Assert.assertEquals("test_queryId", event.getHiveQueryId());
Assert.assertEquals("test_op_id", event.getOperationId());
Assert.assertEquals(ExecutionMode.NONE.name(), event.getExecutionMode());
Assert.assertFalse(event.hasQueue());
assertOtherInfo(event, OtherInfoType.TEZ, Boolean.FALSE.toString());
assertOtherInfo(event, OtherInfoType.MAPRED, Boolean.FALSE.toString());
assertOtherInfo(event, OtherInfoType.CLIENT_IP_ADDRESS, "192.168.10.10");
assertOtherInfo(event, OtherInfoType.SESSION_ID, "test_session_id");
assertOtherInfo(event, OtherInfoType.THREAD_NAME, "test_thread_id");
assertOtherInfo(event, OtherInfoType.HIVE_INSTANCE_TYPE, "HS2");
assertOtherInfo(event, OtherInfoType.HIVE_ADDRESS, "hive_addr");
assertOtherInfo(event, OtherInfoType.CONF, null);
assertOtherInfo(event, OtherInfoType.QUERY, null);
}
use of org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto in project hive by apache.
the class TestHiveProtoLoggingHook method testPostEventLog.
@Test
public void testPostEventLog() throws Exception {
context.setHookType(HookType.POST_EXEC_HOOK);
context.getPerfLogger().perfLogBegin("test", "LogTest");
context.getPerfLogger().perfLogEnd("test", "LogTest");
EventLogger evtLogger = new EventLogger(conf, SystemClock.getInstance());
evtLogger.handle(context);
evtLogger.shutdown();
HiveHookEventProto event = loadEvent(conf, tmpFolder);
Assert.assertEquals(EventType.QUERY_COMPLETED.name(), event.getEventType());
Assert.assertEquals(System.getProperty("user.name"), event.getUser());
Assert.assertEquals("test_user", event.getRequestUser());
Assert.assertEquals("test_queryId", event.getHiveQueryId());
Assert.assertEquals("test_op_id", event.getOperationId());
assertOtherInfo(event, OtherInfoType.STATUS, Boolean.TRUE.toString());
String val = findOtherInfo(event, OtherInfoType.PERF);
Map<String, Long> map = new ObjectMapper().readValue(val, new TypeReference<Map<String, Long>>() {
});
// This should be really close to zero.
Assert.assertTrue("Expected LogTest in PERF", map.get("LogTest") < 100);
}
use of org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto in project hive by apache.
the class TestHiveProtoLoggingHook method loadEvent.
private HiveHookEventProto loadEvent(HiveConf conf, String tmpFolder) throws IOException {
ProtoMessageReader<HiveHookEventProto> reader = getTestReader(conf, tmpFolder);
HiveHookEventProto event = reader.readEvent();
Assert.assertNotNull(event);
return event;
}
Aggregations