Search in sources :

Example 1 with HiveHookEventProto

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");
}
Also used : MapWork(org.apache.hadoop.hive.ql.plan.MapWork) EventLogger(org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger) ExecDriver(org.apache.hadoop.hive.ql.exec.mr.ExecDriver) HiveHookEventProto(org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto) TezTask(org.apache.hadoop.hive.ql.exec.tez.TezTask) TezWork(org.apache.hadoop.hive.ql.plan.TezWork) Test(org.junit.Test)

Example 2 with HiveHookEventProto

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);
}
Also used : EventLogger(org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger) HiveHookEventProto(org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto) Test(org.junit.Test)

Example 3 with HiveHookEventProto

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());
}
Also used : EventLogger(org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger) HiveHookEventProto(org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto) Test(org.junit.Test)

Example 4 with HiveHookEventProto

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) {
    }
}
Also used : EventLogger(org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger) EOFException(java.io.EOFException) HiveHookEventProto(org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto) Test(org.junit.Test)

Example 5 with HiveHookEventProto

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());
}
Also used : Path(org.apache.hadoop.fs.Path) FileStatus(org.apache.hadoop.fs.FileStatus) FileSystem(org.apache.hadoop.fs.FileSystem) HiveHookEventProto(org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto) DatePartitionedLogger(org.apache.tez.dag.history.logging.proto.DatePartitionedLogger)

Aggregations

HiveHookEventProto (org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto)8 EventLogger (org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger)6 Test (org.junit.Test)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 EOFException (java.io.EOFException)1 Map (java.util.Map)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 ExecDriver (org.apache.hadoop.hive.ql.exec.mr.ExecDriver)1 TezTask (org.apache.hadoop.hive.ql.exec.tez.TezTask)1 MapWork (org.apache.hadoop.hive.ql.plan.MapWork)1 TezWork (org.apache.hadoop.hive.ql.plan.TezWork)1 DatePartitionedLogger (org.apache.tez.dag.history.logging.proto.DatePartitionedLogger)1