code: public Task obtainTaskCleanupTask(TaskTrackerStatus tts,
                                                   boolean isMapSlot)
    throws IOException {
      if (!tasksInited.get()) {
        return null;
      }
  
      if (this.status.getRunState() != JobStatus.RUNNING ||
          jobFailed || jobKilled) {
        return null;
      }
  
      if (isMapSlot) {
        if (mapCleanupTasks.isEmpty())
          return null;
      } else {
        if (reduceCleanupTasks.isEmpty())
          return null;
      }
  
      synchronized (this) {
        if (this.status.getRunState() != JobStatus.RUNNING ||
            jobFailed || jobKilled) {
          return null;
        }
        String taskTracker = tts.getTrackerName();
        if (!shouldRunOnTaskTracker(taskTracker)) {
          return null;
        }
        TaskAttemptID taskid = null;
        TaskInProgress tip = null;
        if (isMapSlot) {
          if (!mapCleanupTasks.isEmpty()) {
            taskid = mapCleanupTasks.remove(0);
            tip = maps[taskid.getTaskID().getId()];
          }
        } else {
          if (!reduceCleanupTasks.isEmpty()) {
            taskid = reduceCleanupTasks.remove(0);
            tip = reduces[taskid.getTaskID().getId()];
          }
        }
        if (tip != null) {
          return tip.addRunningTask(taskid, taskTracker, true);
        }
        return null;
      }
    }
docs: /*
  Return task cleanup attempt if any, to run on a given tracker