use of org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger in project hive by apache.
the class TestHiveProtoLoggingHook method testQueueLogs.
@Test
public void testQueueLogs() throws Exception {
context.setHookType(HookType.PRE_EXEC_HOOK);
EventLogger evtLogger = new EventLogger(conf, SystemClock.getInstance());
// This makes it MR task
context.getQueryPlan().getRootTasks().add(new ExecDriver());
evtLogger.handle(context);
// This makes it Tez task
MapWork mapWork = new MapWork();
TezWork tezWork = new TezWork("test_queryid");
tezWork.add(mapWork);
TezTask task = new TezTask();
task.setId("id1");
task.setWork(tezWork);
context.getQueryPlan().getRootTasks().add(task);
context.getQueryPlan().getRootTasks().add(new TezTask());
evtLogger.handle(context);
// This makes it llap task
mapWork.setLlapMode(true);
evtLogger.handle(context);
evtLogger.shutdown();
ProtoMessageReader<HiveHookEventProto> reader = getTestReader(conf, tmpFolder);
HiveHookEventProto event = reader.readEvent();
Assert.assertNotNull(event);
Assert.assertEquals(ExecutionMode.MR.name(), event.getExecutionMode());
Assert.assertEquals(event.getQueue(), "mr_queue");
event = reader.readEvent();
Assert.assertNotNull(event);
Assert.assertEquals(ExecutionMode.TEZ.name(), event.getExecutionMode());
Assert.assertEquals(event.getQueue(), "tez_queue");
event = reader.readEvent();
Assert.assertNotNull(event);
Assert.assertEquals(ExecutionMode.LLAP.name(), event.getExecutionMode());
Assert.assertEquals(event.getQueue(), "llap_queue");
}
use of org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger in project hive by apache.
the class TestHiveProtoLoggingHook method testFailureEventLog.
@Test
public void testFailureEventLog() throws Exception {
context.setHookType(HookType.ON_FAILURE_HOOK);
context.setErrorMessage("test_errormessage");
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.FALSE.toString());
assertOtherInfo(event, OtherInfoType.ERROR_MESSAGE, "test_errormessage");
assertOtherInfo(event, OtherInfoType.PERF, null);
}
use of org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger in project hive by apache.
the class TestHiveProtoLoggingHook method testPreAndPostEventBoth.
@Test
public void testPreAndPostEventBoth() throws Exception {
context.setHookType(HookType.PRE_EXEC_HOOK);
EventLogger evtLogger = new EventLogger(conf, SystemClock.getInstance());
evtLogger.handle(context);
context.setHookType(HookType.POST_EXEC_HOOK);
evtLogger.handle(context);
evtLogger.shutdown();
ProtoMessageReader<HiveHookEventProto> reader = getTestReader(conf, tmpFolder);
HiveHookEventProto event = reader.readEvent();
Assert.assertNotNull("Pre hook event not found", event);
Assert.assertEquals(EventType.QUERY_SUBMITTED.name(), event.getEventType());
event = reader.readEvent();
Assert.assertNotNull("Post hook event not found", event);
Assert.assertEquals(EventType.QUERY_COMPLETED.name(), event.getEventType());
}
use of org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger in project hive by apache.
the class TestHiveProtoLoggingHook method testDropsEventWhenQueueIsFull.
@org.junit.Ignore("might fail intermittently")
@Test
public void testDropsEventWhenQueueIsFull() throws Exception {
EventLogger evtLogger = new EventLogger(conf, SystemClock.getInstance());
context.setHookType(HookType.PRE_EXEC_HOOK);
evtLogger.handle(context);
evtLogger.handle(context);
evtLogger.handle(context);
evtLogger.handle(context);
evtLogger.shutdown();
ProtoMessageReader<HiveHookEventProto> reader = getTestReader(conf, tmpFolder);
reader.readEvent();
reader.readEvent();
reader.readEvent();
try {
reader.readEvent();
Assert.fail("Expected 3 events due to queue capacity limit, got 4.");
} catch (EOFException expected) {
}
}
use of org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger 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);
}
Aggregations