@Test public void testMapEventToJobLog() { List<Event> applicationEvents = eventBuilder(); yarnConf.unset("yarn.nodemanager.webapp.address"); List<JobLog> jobEvents = ParserUtils.mapEventToJobLog(applicationEvents, new JobLogMetaData(yarnConf, "testuser")); yarnConf.set("yarn.nodemanager.webapp.address", "0.0.0.0:8042"); assertEquals(jobEvents.get(0).getLogLink(), DEFAULT_VALUE_OF_CONTAINER_LOG_LINK); yarnConf.set("yarn.nodemanager.webapp.address", "0.0.0.0:8042"); jobEvents = ParserUtils.mapEventToJobLog(applicationEvents, new JobLogMetaData(yarnConf, "testuser")); assertEquals(jobEvents.get(0).getLogLink(), "http: assertEquals(jobEvents.get(1).getLogLink(), "http: yarnConf.set("yarn.nodemanager.webapp.address", "0.0.0.0"); jobEvents = ParserUtils.mapEventToJobLog(applicationEvents, new JobLogMetaData(yarnConf, "testuser")); assertEquals(jobEvents.get(0).getLogLink(), DEFAULT_VALUE_OF_CONTAINER_LOG_LINK); jobEvents = ParserUtils.mapEventToJobLog(applicationEvents, new JobLogMetaData(null, null)); assertEquals(jobEvents.get(0).getLogLink(), DEFAULT_VALUE_OF_CONTAINER_LOG_LINK); assertEquals(jobEvents.get(1).getLogLink(), DEFAULT_VALUE_OF_CONTAINER_LOG_LINK); assertEquals("fakecontainerID", JobLog.convertEventToJobLog(applicationEvents.get(0), new JobLogMetaData(yarnConf, "testuser")) .getContainerID()); assertEquals("fakecontainerID1", JobLog.convertEventToJobLog(applicationEvents.get(1), new JobLogMetaData(yarnConf, "testuser")) .getContainerID()); assertNull(JobLog.convertEventToJobLog(applicationEvents.get(2), new JobLogMetaData(yarnConf, "testuser")) .getContainerID()); assertNull(JobLog.convertEventToJobLog(applicationEvents.get(3), new JobLogMetaData(yarnConf, "testuser")) .getContainerID()); }
public static List<JobLog> mapEventToJobLog(List<Event> events, JobLogMetaData jobLogMetaData) { return events.stream() .map(e -> JobLog.convertEventToJobLog(e, jobLogMetaData)) .filter(jobLog -> jobLog.getContainerID() != null) .collect(Collectors.toList()); }
ParserUtils { public static List<JobLog> mapEventToJobLog(List<Event> events, JobLogMetaData jobLogMetaData) { return events.stream() .map(e -> JobLog.convertEventToJobLog(e, jobLogMetaData)) .filter(jobLog -> jobLog.getContainerID() != null) .collect(Collectors.toList()); } }
ParserUtils { public static List<JobLog> mapEventToJobLog(List<Event> events, JobLogMetaData jobLogMetaData) { return events.stream() .map(e -> JobLog.convertEventToJobLog(e, jobLogMetaData)) .filter(jobLog -> jobLog.getContainerID() != null) .collect(Collectors.toList()); } private  ParserUtils(); }
ParserUtils { public static List<JobLog> mapEventToJobLog(List<Event> events, JobLogMetaData jobLogMetaData) { return events.stream() .map(e -> JobLog.convertEventToJobLog(e, jobLogMetaData)) .filter(jobLog -> jobLog.getContainerID() != null) .collect(Collectors.toList()); } private  ParserUtils(); @VisibleForTesting static boolean isValidHistFileName(String fileName, String jobIdRegex); static String getJhistFilePath(FileSystem fs, Path jobFolderPath); static long getCompletedTimeFromJhistFileName(String jhistFileName); static JobMetadata parseMetadata(FileSystem fs, YarnConfiguration yarnConf, Path jobFolderPath, String jobIdRegex); static List<JobConfig> parseConfig(FileSystem fs, Path jobFolderPath); static List<Event> parseEvents(FileSystem fs, Path jobFolderPath); static List<JobEvent> mapEventToJobEvent(List<Event> events); static List<JobLog> mapEventToJobLog(List<Event> events, JobLogMetaData jobLogMetaData); static String getYearMonthDayDirectory(Date date, ZoneId zoneId); }
ParserUtils { public static List<JobLog> mapEventToJobLog(List<Event> events, JobLogMetaData jobLogMetaData) { return events.stream() .map(e -> JobLog.convertEventToJobLog(e, jobLogMetaData)) .filter(jobLog -> jobLog.getContainerID() != null) .collect(Collectors.toList()); } private  ParserUtils(); @VisibleForTesting static boolean isValidHistFileName(String fileName, String jobIdRegex); static String getJhistFilePath(FileSystem fs, Path jobFolderPath); static long getCompletedTimeFromJhistFileName(String jhistFileName); static JobMetadata parseMetadata(FileSystem fs, YarnConfiguration yarnConf, Path jobFolderPath, String jobIdRegex); static List<JobConfig> parseConfig(FileSystem fs, Path jobFolderPath); static List<Event> parseEvents(FileSystem fs, Path jobFolderPath); static List<JobEvent> mapEventToJobEvent(List<Event> events); static List<JobLog> mapEventToJobLog(List<Event> events, JobLogMetaData jobLogMetaData); static String getYearMonthDayDirectory(Date date, ZoneId zoneId);  }