OozieAuditLogParser { public OozieAuditLogObject parse(String logLine) throws Exception { OozieAuditLogObject oozieAuditLogObject = new OozieAuditLogObject(); Matcher matcher = LOG_PATTERN.matcher(logLine); if (!matcher.matches()) { return null; } applyValueTo(oozieAuditLogObject, matcher); return oozieAuditLogObject; }  OozieAuditLogObject parse(String logLine); static final String MESSAGE_SPLIT_FLAG; static final String ALLOW_ALL_REGEX; }
@Test public void testParser() throws Exception { String logline = "2016-04-27 15:01:14,526 INFO oozieaudit:520 - IP [192.168.7.199], USER [tangjijun], GROUP [pms], APP [My_Workflow], JOBID [0000000-160427140648764-oozie-oozi-W], " + "OPERATION [start], PARAMETER [0000000-160427140648764-oozie-oozi-W], STATUS [SUCCESS], HTTPCODE [200], ERRORCODE [501], ERRORMESSAGE [no problem]"; OozieAuditLogObject obj = parser.parse(logline); Assert.assertEquals("192.168.7.199",obj.ip); Assert.assertEquals("tangjijun",obj.user); Assert.assertEquals("pms",obj.group); Assert.assertEquals("My_Workflow",obj.app); Assert.assertEquals("0000000-160427140648764-oozie-oozi-W",obj.jobId); Assert.assertEquals("start",obj.operation); Assert.assertEquals("0000000-160427140648764-oozie-oozi-W",obj.parameter); Assert.assertEquals("SUCCESS",obj.status); Assert.assertEquals("200",obj.httpcode); Assert.assertEquals("501",obj.errorcode); Assert.assertEquals("no problem",obj.errormessage); Assert.assertEquals("INFO",obj.level); Assert.assertEquals(1461769274526L,obj.timestamp); }
@Test public void testParserNotMatch() throws Exception { String logline =" 2016-04-27 16:11:37,156 INFO oozieaudit:520 - Proxy user [hue] DoAs user [tangjijun] Request [http: OozieAuditLogObject obj = parser.parse(logline); Assert.assertTrue(obj == null); }