use of org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto 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.proto.HiveHookEvents.HiveHookEventProto 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.proto.HiveHookEvents.HiveHookEventProto 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.proto.HiveHookEvents.HiveHookEventProto 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.proto.HiveHookEvents.HiveHookEventProto in project hive by apache.
the class TestHiveProtoLoggingHook method getTestReader.
public static ProtoMessageReader<HiveHookEventProto> getTestReader(HiveConf conf, String tmpFolder) throws IOException {
Path path = new Path(tmpFolder);
FileSystem fs = path.getFileSystem(conf);
FileStatus[] status = fs.listStatus(path);
Assert.assertEquals(1, status.length);
status = fs.listStatus(status[0].getPath());
Assert.assertEquals(1, status.length);
DatePartitionedLogger<HiveHookEventProto> logger = new DatePartitionedLogger<>(HiveHookEventProto.PARSER, path, conf, SystemClock.getInstance());
return logger.getReader(status[0].getPath());
}
Aggregations