Search in sources :

Example 6 with EventLogger

use of org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger 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);
}
Also used : EventLogger(org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger) AtomicLong(java.util.concurrent.atomic.AtomicLong) HiveHookEventProto(org.apache.hadoop.hive.ql.hooks.proto.HiveHookEvents.HiveHookEventProto) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 7 with EventLogger

use of org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger in project hive by apache.

the class TestHiveProtoLoggingHook method testRolloverFiles.

@Test
public void testRolloverFiles() throws Exception {
    long waitTime = 100;
    context.setHookType(HookType.PRE_EXEC_HOOK);
    conf.setTimeDuration(ConfVars.HIVE_PROTO_EVENTS_ROLLOVER_CHECK_INTERVAL.varname, waitTime, TimeUnit.MICROSECONDS);
    Path path = new Path(tmpFolder);
    FileSystem fs = path.getFileSystem(conf);
    AtomicLong time = new AtomicLong();
    EventLogger evtLogger = new EventLogger(conf, () -> time.get());
    evtLogger.handle(context);
    int statusLen = 0;
    // Loop to ensure that we give some grace for scheduling issues.
    for (int i = 0; i < 3; ++i) {
        Thread.sleep(waitTime + 100);
        statusLen = fs.listStatus(path).length;
        if (statusLen > 0) {
            break;
        }
    }
    Assert.assertEquals(1, statusLen);
    // Move to next day and ensure a new file gets created.
    time.set(24 * 60 * 60 * 1000 + 1000);
    for (int i = 0; i < 3; ++i) {
        Thread.sleep(waitTime + 100);
        statusLen = fs.listStatus(path).length;
        if (statusLen > 1) {
            break;
        }
    }
    Assert.assertEquals(2, statusLen);
}
Also used : Path(org.apache.hadoop.fs.Path) AtomicLong(java.util.concurrent.atomic.AtomicLong) EventLogger(org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook.EventLogger) FileSystem(org.apache.hadoop.fs.FileSystem) 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