/**
   * Given the reduce taskAttemptID, returns the TaskAttemptInfo. Deconstructs the reduce
   * taskAttemptID and looks up the jobStory with the parts taskType, id of task, id of task
   * attempt.
   *
   * @param taskTracker tasktracker
   * @param taskAttemptID task-attempt
   * @return TaskAttemptInfo for the reduce task-attempt
   */
  private TaskAttemptInfo getReduceTaskAttemptInfo(
      TaskTracker taskTracker, TaskAttemptID taskAttemptID) {
    assert (!taskAttemptID.isMap());
    TaskID taskId = taskAttemptID.getTaskID();
    TaskType taskType;
    if (taskAttemptID.isMap()) {
      taskType = TaskType.MAP;
    } else {
      taskType = TaskType.REDUCE;
    }

    TaskAttemptInfo taskAttemptInfo =
        jobStory.getTaskAttemptInfo(taskType, taskId.getId(), taskAttemptID.getId());
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "get an attempt: "
              + taskAttemptID.toString()
              + ", state="
              + taskAttemptInfo.getRunState()
              + ", runtime="
              + ((taskAttemptID.isMap())
                  ? taskAttemptInfo.getRuntime()
                  : ((ReduceTaskAttemptInfo) taskAttemptInfo).getReduceRuntime()));
    }
    return taskAttemptInfo;
  }
  /**
   * Given the map taskAttemptID, returns the TaskAttemptInfo. Deconstructs the map's taskAttemptID
   * and looks up the jobStory with the parts taskType, id of task, id of task attempt.
   *
   * @param taskTracker tasktracker
   * @param taskAttemptID task-attempt
   * @return TaskAttemptInfo for the map task-attempt
   */
  @SuppressWarnings("deprecation")
  private synchronized TaskAttemptInfo getMapTaskAttemptInfo(
      TaskTracker taskTracker, TaskAttemptID taskAttemptID) {
    assert (taskAttemptID.isMap());

    JobID jobid = (JobID) taskAttemptID.getJobID();
    assert (jobid == getJobID());

    // Get splits for the TaskAttempt
    RawSplit split = splits[taskAttemptID.getTaskID().getId()];
    int locality = getClosestLocality(taskTracker, split);

    TaskID taskId = taskAttemptID.getTaskID();
    if (!taskId.isMap()) {
      assert false : "Task " + taskId + " is not MAP :";
    }

    TaskAttemptInfo taskAttemptInfo =
        jobStory.getMapTaskAttemptInfoAdjusted(taskId.getId(), taskAttemptID.getId(), locality);

    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "get an attempt: "
              + taskAttemptID.toString()
              + ", state="
              + taskAttemptInfo.getRunState()
              + ", runtime="
              + ((taskId.isMap())
                  ? taskAttemptInfo.getRuntime()
                  : ((ReduceTaskAttemptInfo) taskAttemptInfo).getReduceRuntime()));
    }
    return taskAttemptInfo;
  }