private String writeThrowableAsFile(String before, Throwable t, String after, String fileSuffix, TaskLogProcessor taskLogProcessor) throws IOException { // compose file text: StringBuilder sb = new StringBuilder(); if (before != null) { sb.append(before); } final String stackTraceStr = toString(t); sb.append(stackTraceStr); if (after != null) { sb.append(after); } // write it to file: File file = writeTestLog(fileSuffix, sb.toString()); // add it to the log processor: taskLogProcessor.addTaskAttemptLogUrl(file.toURI().toURL().toString()); return stackTraceStr; }
tlp.addTaskAttemptLogUrl(logUrl);
tlp.addTaskAttemptLogUrl(logUrl);
@Test public void testScriptErrorHeuristic() throws Exception { JobConf jobConf = new JobConf(); HiveConf.setQueryString(jobConf, "select * from foo group by moo;"); final TaskLogProcessor taskLogProcessor = new TaskLogProcessor(jobConf); String errorCode = "7874"; // example code String content = "line a\nlineb\n" + "Script failed with code " + errorCode + " line c\nlineD\n"; File log3File = writeTestLog("1", content); taskLogProcessor.addTaskAttemptLogUrl(log3File.toURI().toURL().toString()); List<ErrorAndSolution> errList = taskLogProcessor.getErrors(); assertEquals(1, errList.size()); final ErrorAndSolution eas = errList.get(0); String error = eas.getError(); assertNotNull(error); // check that the error code is present in the error description: assertTrue(error.indexOf(errorCode) >= 0); String solution = eas.getSolution(); assertNotNull(solution); assertTrue(solution.length() > 0); }
@Test public void testMapAggrMemErrorHeuristic() throws Exception { JobConf jobConf = new JobConf(); HiveConf.setQueryString(jobConf, "select * from foo group by moo;"); final TaskLogProcessor taskLogProcessor = new TaskLogProcessor(jobConf); Throwable oome = new OutOfMemoryError("java heap space"); File log1File = writeTestLog("1", toString(oome)); taskLogProcessor.addTaskAttemptLogUrl(log1File.toURI().toURL().toString()); List<ErrorAndSolution> errList = taskLogProcessor.getErrors(); assertEquals(1, errList.size()); final ErrorAndSolution eas = errList.get(0); String error = eas.getError(); assertNotNull(error); // check that the error code is present in the error description: assertTrue(error.contains("memory")); String solution = eas.getSolution(); assertNotNull(solution); assertTrue(solution.length() > 0); String confName = HiveConf.ConfVars.HIVEMAPAGGRHASHMEMORY.toString(); assertTrue(solution.contains(confName)); }
+ "line E\n"; File log3File = writeTestLog("1", content); taskLogProcessor.addTaskAttemptLogUrl(log3File.toURI().toURL().toString());