FileNameIndexUtils { private static String trimJobName(String jobName, int jobNameLimit) { if (jobName.length() > jobNameLimit) { jobName = jobName.substring(0, jobNameLimit); } return jobName; }  static String getDoneFileName(JobIndexInfo indexInfo); static String getDoneFileName(JobIndexInfo indexInfo,
      int jobNameLimit); static JobIndexInfo getIndexInfo(String jhFileName); static String encodeJobHistoryFileName(String logFileName); static String decodeJobHistoryFileName(String logFileName);  }
@Test public void testTrimJobName() throws IOException { int jobNameTrimLength = 5; JobIndexInfo info = new JobIndexInfo(); JobID oldJobId = JobID.forName(JOB_ID); JobId jobId = TypeConverter.toYarn(oldJobId); info.setJobId(jobId); info.setSubmitTime(Long.parseLong(SUBMIT_TIME)); info.setUser(USER_NAME); info.setJobName(JOB_NAME); info.setFinishTime(Long.parseLong(FINISH_TIME)); info.setNumMaps(Integer.parseInt(NUM_MAPS)); info.setNumReduces(Integer.parseInt(NUM_REDUCES)); info.setJobStatus(JOB_STATUS); info.setQueueName(QUEUE_NAME); info.setJobStartTime(Long.parseLong(JOB_START_TIME)); String jobHistoryFile = FileNameIndexUtils.getDoneFileName(info, jobNameTrimLength); JobIndexInfo parsedInfo = FileNameIndexUtils.getIndexInfo(jobHistoryFile); Assert.assertEquals("Job name did not get trimmed correctly", info.getJobName().substring(0, jobNameTrimLength), parsedInfo.getJobName()); }