private void addJobsForHistoryDir(String historyDir, List<AnalyticJob> jobs, long startTime, long endTime)
      throws Exception {
    if (_fs.exists(new Path(historyDir))) {
      RemoteIterator<LocatedFileStatus> it = _fs.listFiles(new Path(historyDir), true);
      while (it.hasNext()) {
        String histFilename = it.next().getPath().getName();
        if (histFilename.endsWith(".jhist")) {
          try {
            JobIndexInfo indexInfo = FileNameIndexUtils.getIndexInfo(histFilename);
            String appId = Utils.getApplicationIdFromJobId(indexInfo.getJobId().toString());
            // Add the job only if required.
            if (indexInfo.getFinishTime() >= startTime && indexInfo.getFinishTime() <= endTime) {
              jobs.add(new AnalyticJob().setAppId(appId).setStartTime(indexInfo.getSubmitTime()).
                  setFinishTime(indexInfo.getFinishTime()).setName(indexInfo.getJobName()).
                  setUser(indexInfo.getUser()).setQueueName(indexInfo.getQueueName()).
                  setAppType(_fetcherConfigurationData.getAppType()));
            }
          } catch (IOException e) {
            // Fall back to parsing the filename by ourselves.
            String[] jobDetails = histFilename.split("-");
            jobs.add(new AnalyticJob().setAppId(Utils.getApplicationIdFromJobId(jobDetails[0])).
                setAppType(_fetcherConfigurationData.getAppType()));
          }
        }
      }
    }
  }
The location of a job history file is in format: {done-dir}/yyyy/mm/dd/{serialPart}.
yyyy/mm/dd is the year, month and date of the finish time.
serialPart is the first 6 digits of the serial number considering it as a 9 digits number.
PS: The serial number is the last part of an app id.
<p>
For example, if appId = application_1461566847127_84624, then serial number is 84624.
Consider it as a 9 digits number, serial number is 000084624. So the corresponding
serialPart is 000084. If this application finish at 2016-5-30, its history file will locate
at {done-dir}/2016/05/30/000084
</p>
<p>
Furthermore, this location format is only satisfied for finished jobs in {done-dir} and not
for running jobs in {intermediate-done-dir}.
</p>
app/com/linkedin/drelephant/mapreduce/fetchers/MapReduceFSFetcherHadoop2.java