code: synchronized List<TaskTrackerAction> getTasksToKill(String taskTracker) {
  
      Set<TaskAttemptIDWithTip> taskset = trackerToTaskMap.get(taskTracker);
      List<TaskTrackerAction> killList = new ArrayList<TaskTrackerAction>();
      if (taskset != null) {
        for (TaskAttemptIDWithTip onetask : taskset) {
          TaskAttemptID killTaskId = onetask.attemptId;
          TaskInProgress tip = onetask.tip;
  
          if (tip == null) {
            continue;
          }
          if (tip.shouldClose(killTaskId)) {
            //
            // This is how the JobTracker ends a task at the TaskTracker.
            // It may be successfully completed, or may be killed in
            // mid-execution.
            //
            if (!((JobInProgress)tip.getJob()).isComplete()) {
              killList.add(new KillTaskAction(killTaskId));
              LOG.debug(taskTracker + " -> KillTaskAction: " + killTaskId);
            }
          }
        }
      }
  
      // add the stray attempts for uninited jobs
      synchronized (trackerToTasksToCleanup) {
        Set<TaskAttemptID> set = trackerToTasksToCleanup.remove(taskTracker);
        if (set != null) {
          for (TaskAttemptID id : set) {
            killList.add(new KillTaskAction(id));
          }
        }
      }
      return killList;
    }
docs: A tracker wants to know if any of its Tasks have been
  closed (because the job completed, whether successfully or not)