Search in sources :

Example 1 with EventLogger

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");
}
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 EventLogger

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);
}
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 EventLogger

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());
}
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 EventLogger

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) {
    }
}
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 EventLogger

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);
}
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)

Aggregations

EventLogger (org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger)7 Test (org.junit.Test)7 HiveHookEventProto (org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 EOFException (java.io.EOFException)1 Map (java.util.Map)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