@Test public void testIsValidHistFileNameTrue() { String fileName = "job123-1-1-user1-FAILED." + Constants.HISTFILE_SUFFIX; String jobRegex = "job\\d+"; assertTrue(ParserUtils.isValidHistFileName(fileName, jobRegex)); }
@VisibleForTesting public static boolean isValidHistFileName(String fileName, String jobIdRegex) { if (Strings.isNullOrEmpty(fileName)) { LOG.error("No filename provided!"); return false; } String histFileNoExt = fileName.substring(0, fileName.indexOf('.')); String[] metadataArr = histFileNoExt.split("-"); if (metadataArr.length < 3) { LOG.error("Missing fields in metadata"); return false; } if (fileName.endsWith(Constants.INPROGRESS)) { return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches(metadataArr[2].toLowerCase()); } Preconditions.checkArgument(metadataArr.length == 5); return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches("\\d+") && metadataArr[3].matches(metadataArr[3].toLowerCase()) && metadataArr[4].equals(metadataArr[4].toUpperCase()); }
ParserUtils { @VisibleForTesting public static boolean isValidHistFileName(String fileName, String jobIdRegex) { if (Strings.isNullOrEmpty(fileName)) { LOG.error("No filename provided!"); return false; } String histFileNoExt = fileName.substring(0, fileName.indexOf('.')); String[] metadataArr = histFileNoExt.split("-"); if (metadataArr.length < 3) { LOG.error("Missing fields in metadata"); return false; } if (fileName.endsWith(Constants.INPROGRESS)) { return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches(metadataArr[2].toLowerCase()); } Preconditions.checkArgument(metadataArr.length == 5); return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches("\\d+") && metadataArr[3].matches(metadataArr[3].toLowerCase()) && metadataArr[4].equals(metadataArr[4].toUpperCase()); } }
ParserUtils { @VisibleForTesting public static boolean isValidHistFileName(String fileName, String jobIdRegex) { if (Strings.isNullOrEmpty(fileName)) { LOG.error("No filename provided!"); return false; } String histFileNoExt = fileName.substring(0, fileName.indexOf('.')); String[] metadataArr = histFileNoExt.split("-"); if (metadataArr.length < 3) { LOG.error("Missing fields in metadata"); return false; } if (fileName.endsWith(Constants.INPROGRESS)) { return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches(metadataArr[2].toLowerCase()); } Preconditions.checkArgument(metadataArr.length == 5); return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches("\\d+") && metadataArr[3].matches(metadataArr[3].toLowerCase()) && metadataArr[4].equals(metadataArr[4].toUpperCase()); } private  ParserUtils(); }
ParserUtils { @VisibleForTesting public static boolean isValidHistFileName(String fileName, String jobIdRegex) { if (Strings.isNullOrEmpty(fileName)) { LOG.error("No filename provided!"); return false; } String histFileNoExt = fileName.substring(0, fileName.indexOf('.')); String[] metadataArr = histFileNoExt.split("-"); if (metadataArr.length < 3) { LOG.error("Missing fields in metadata"); return false; } if (fileName.endsWith(Constants.INPROGRESS)) { return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches(metadataArr[2].toLowerCase()); } Preconditions.checkArgument(metadataArr.length == 5); return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches("\\d+") && metadataArr[3].matches(metadataArr[3].toLowerCase()) && metadataArr[4].equals(metadataArr[4].toUpperCase()); } 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 { @VisibleForTesting public static boolean isValidHistFileName(String fileName, String jobIdRegex) { if (Strings.isNullOrEmpty(fileName)) { LOG.error("No filename provided!"); return false; } String histFileNoExt = fileName.substring(0, fileName.indexOf('.')); String[] metadataArr = histFileNoExt.split("-"); if (metadataArr.length < 3) { LOG.error("Missing fields in metadata"); return false; } if (fileName.endsWith(Constants.INPROGRESS)) { return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches(metadataArr[2].toLowerCase()); } Preconditions.checkArgument(metadataArr.length == 5); return metadataArr[0].matches(jobIdRegex) && metadataArr[1].matches("\\d+") && metadataArr[2].matches("\\d+") && metadataArr[3].matches(metadataArr[3].toLowerCase()) && metadataArr[4].equals(metadataArr[4].toUpperCase()); } 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);  }