private DataFiles getHistoryFiles(AnalyticJob job) throws IOException {
    String jobId = Utils.getJobIdFromApplicationId(job.getAppId());
    String jobConfPath = null;
    String jobHistPath = null;

    // Search files in done dir
    String jobHistoryDirPath = getHistoryDir(job);

    if (_fs.exists(new Path(jobHistoryDirPath))) {
      RemoteIterator<LocatedFileStatus> it = _fs.listFiles(new Path(jobHistoryDirPath), false);
      while (it.hasNext() && (jobConfPath == null || jobHistPath == null)) {
        String name = it.next().getPath().getName();
        if (name.contains(jobId)) {
          if (name.endsWith("_conf.xml")) {
            jobConfPath = jobHistoryDirPath + name;
          } else if (name.endsWith(".jhist")) {
            jobHistPath = jobHistoryDirPath + name;
          }
        }
      }
    }

    // If some files are missing, search in the intermediate-done-dir in case the HistoryServer has
    // not yet moved them into the done-dir.
    String intermediateDirPath = _intermediateHistoryLocation + File.separator + job.getUser() + File.separator;
    if (jobConfPath == null) {
      jobConfPath = intermediateDirPath + jobId + "_conf.xml";
      if (!_fs.exists(new Path(jobConfPath))) {
        throw new FileNotFoundException("Can't find config of " + jobId + " in neither "
                + jobHistoryDirPath + " nor " + intermediateDirPath);
      }
      logger.info("Found job config in intermediate dir: " + jobConfPath);
    }
    if (jobHistPath == null) {
      try {
        RemoteIterator<LocatedFileStatus> it = _fs.listFiles(new Path(intermediateDirPath), false);
        while (it.hasNext()) {
          String name = it.next().getPath().getName();
          if (name.contains(jobId) && name.endsWith(".jhist")) {
            jobHistPath = intermediateDirPath + name;
            logger.info("Found history file in intermediate dir: " + jobHistPath);
            break;
          }
        }
      } catch (FileNotFoundException e) {
        logger.error("Intermediate history directory " + intermediateDirPath + " not found");
      }
      if (jobHistPath == null) {
        throw new FileNotFoundException("Can't find history file of " + jobId + " in neither "
                + jobHistoryDirPath + " nor " + intermediateDirPath);
      }
    }

    return new DataFiles(jobConfPath, jobHistPath);
  }
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