@Test public void testParseMetadataFailIOException() throws IOException { Path jobFolder = new Path(Constants.TONY_CORE_SRC + "test/resources/typicalHistFolder/job1"); String jobRegex = "application\\d+"; FileSystem mockFs = mock(FileSystem.class); when(mockFs.listStatus(jobFolder)).thenThrow(new IOException("IO Excpt")); JobMetadata result = ParserUtils.parseMetadata(mockFs, yarnConf, jobFolder, jobRegex); assertNull(result); }
public static JobMetadata parseMetadata(FileSystem fs, YarnConfiguration yarnConf, Path jobFolderPath, String jobIdRegex) { if (!pathExists(fs, jobFolderPath)) { return null; } String jhistFilePath = getJhistFilePath(fs, jobFolderPath); if (Strings.isNullOrEmpty(jhistFilePath)) { return null; } String histFileName = HdfsUtils.getLastComponent(jhistFilePath); if (!isValidHistFileName(histFileName, jobIdRegex)) { LOG.warn("Invalid history file name " + histFileName); return null; } LOG.debug("Successfully parsed metadata"); return JobMetadata.newInstance(yarnConf, histFileName); }
ParserUtils { public static JobMetadata parseMetadata(FileSystem fs, YarnConfiguration yarnConf, Path jobFolderPath, String jobIdRegex) { if (!pathExists(fs, jobFolderPath)) { return null; } String jhistFilePath = getJhistFilePath(fs, jobFolderPath); if (Strings.isNullOrEmpty(jhistFilePath)) { return null; } String histFileName = HdfsUtils.getLastComponent(jhistFilePath); if (!isValidHistFileName(histFileName, jobIdRegex)) { LOG.warn("Invalid history file name " + histFileName); return null; } LOG.debug("Successfully parsed metadata"); return JobMetadata.newInstance(yarnConf, histFileName); } }
ParserUtils { public static JobMetadata parseMetadata(FileSystem fs, YarnConfiguration yarnConf, Path jobFolderPath, String jobIdRegex) { if (!pathExists(fs, jobFolderPath)) { return null; } String jhistFilePath = getJhistFilePath(fs, jobFolderPath); if (Strings.isNullOrEmpty(jhistFilePath)) { return null; } String histFileName = HdfsUtils.getLastComponent(jhistFilePath); if (!isValidHistFileName(histFileName, jobIdRegex)) { LOG.warn("Invalid history file name " + histFileName); return null; } LOG.debug("Successfully parsed metadata"); return JobMetadata.newInstance(yarnConf, histFileName); } private  ParserUtils(); }
ParserUtils { public static JobMetadata parseMetadata(FileSystem fs, YarnConfiguration yarnConf, Path jobFolderPath, String jobIdRegex) { if (!pathExists(fs, jobFolderPath)) { return null; } String jhistFilePath = getJhistFilePath(fs, jobFolderPath); if (Strings.isNullOrEmpty(jhistFilePath)) { return null; } String histFileName = HdfsUtils.getLastComponent(jhistFilePath); if (!isValidHistFileName(histFileName, jobIdRegex)) { LOG.warn("Invalid history file name " + histFileName); return null; } LOG.debug("Successfully parsed metadata"); return JobMetadata.newInstance(yarnConf, histFileName); } 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 JobMetadata parseMetadata(FileSystem fs, YarnConfiguration yarnConf, Path jobFolderPath, String jobIdRegex) { if (!pathExists(fs, jobFolderPath)) { return null; } String jhistFilePath = getJhistFilePath(fs, jobFolderPath); if (Strings.isNullOrEmpty(jhistFilePath)) { return null; } String histFileName = HdfsUtils.getLastComponent(jhistFilePath); if (!isValidHistFileName(histFileName, jobIdRegex)) { LOG.warn("Invalid history file name " + histFileName); return null; } LOG.debug("Successfully parsed metadata"); return JobMetadata.newInstance(yarnConf, histFileName); } 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);  }