The primary public method that should be called to 'run' a task. Handles
both map and reduce tasks and marks them as completed after the configured
time interval
@param tip
347619
public void launchTask(TaskInProgress tip) throws IOException {
    LOG.info("Launching simulated task " + tip.getTask().getTaskID() +
        " for job " + tip.getTask().getJobID());
    TaskUmbilicalProtocol umbilicalProtocol = taskTracker.getUmbilical(tip);
    // For map tasks, we can just finish the task after some time. Same thing
    // with cleanup tasks, as we don't need to be waiting for mappers to finish
    if (tip.getTask().isMapTask() || tip.getTask().isTaskCleanupTask() ||
      tip.getTask().isJobCleanupTask() || tip.getTask().isJobSetupTask() ) {
      addTipToFinish(tip, umbilicalProtocol);
    } else {
      MapperWaitThread mwt =
          new MapperWaitThread(tip, this, umbilicalProtocol);
      // Save a reference to the mapper wait thread so that we can stop them if
      // the task gets killed
      mapperWaitThreadMap.put(tip, mwt);
      mwt.start();
    }

  }
1149912
protected synchronized void scheduleReduce(TaskInProgress tip) {
    runningReduceTaskStats.add(0.0f);
    runningTaskCopyProcessingRateStats.add(0.0f);
    runningTaskSortProcessingRateStats.add(0.0f);
    runningTaskReduceProcessingRateStats.add(0.0f);
    if (runningReduces == null) {
      LOG.warn("Running cache for reducers missing!! "
               + "Job details are missing.");
      return;
    }
    runningReduces.add(tip);
  }
458527
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;
    }
  }
1024938
void reportTaskFinished(TaskAttemptID taskid, boolean commitPending) {
    TaskInProgress tip;
    synchronized (this) {
      tip = tasks.get(taskid);
    }
    if (tip != null) {
      tip.reportTaskFinished(commitPending);
    } else {
      LOG.warn("Unknown child task finished: "+taskid+". Ignored.");
    }
  }
152664
void markCompletedJob(JobInProgress job) {
    for (TaskInProgress tip : job.getTasks(TaskType.JOB_SETUP)) {
      for (TaskStatus taskStatus : tip.getTaskStatuses()) {
        if (taskStatus.getRunState() != TaskStatus.State.RUNNING &&
            taskStatus.getRunState() != TaskStatus.State.COMMIT_PENDING &&
            taskStatus.getRunState() != TaskStatus.State.UNASSIGNED) {
          markCompletedTaskAttempt(taskStatus.getTaskTracker(),
                                   taskStatus.getTaskID());
        }
      }
    }
    for (TaskInProgress tip : job.getTasks(TaskType.MAP)) {
      for (TaskStatus taskStatus : tip.getTaskStatuses()) {
        if (taskStatus.getRunState() != TaskStatus.State.RUNNING &&
            taskStatus.getRunState() != TaskStatus.State.COMMIT_PENDING &&
            taskStatus.getRunState() != TaskStatus.State.FAILED_UNCLEAN &&
            taskStatus.getRunState() != TaskStatus.State.KILLED_UNCLEAN &&
            taskStatus.getRunState() != TaskStatus.State.UNASSIGNED) {
          markCompletedTaskAttempt(taskStatus.getTaskTracker(),
                                   taskStatus.getTaskID());
        }
      }
    }
    for (TaskInProgress tip : job.getTasks(TaskType.REDUCE)) {
      for (TaskStatus taskStatus : tip.getTaskStatuses()) {
        if (taskStatus.getRunState() != TaskStatus.State.RUNNING &&
            taskStatus.getRunState() != TaskStatus.State.COMMIT_PENDING &&
            taskStatus.getRunState() != TaskStatus.State.FAILED_UNCLEAN &&
            taskStatus.getRunState() != TaskStatus.State.KILLED_UNCLEAN &&
            taskStatus.getRunState() != TaskStatus.State.UNASSIGNED) {
          markCompletedTaskAttempt(taskStatus.getTaskTracker(),
                                   taskStatus.getTaskID());
        }
      }
    }
  }
1106193
protected synchronized void postTaskExecution() {
		if (stopped) {
			// Stopped, so don't count the task(s) as done.
			// (worker threads call this method even if the task was not really executed.)
			return;
		}
		tasksDoneCount++;
		int percentageComplete = tasksDoneCount * 100 / tasksTotalCount;

		// Compute the progress and notify the listeners
		this.notifyListenersSpiderProgress(percentageComplete, tasksDoneCount, tasksTotalCount - tasksDoneCount);

		// Check for ending conditions
		if (tasksDoneCount == tasksTotalCount && initialized) {
			this.complete();
		}
	}
286086
public void markTaskCompletion() {
    if (this.countDownLatch.isPresent()) {
      this.countDownLatch.get().countDown();
    }

    this.taskState.setProp(ConfigurationKeys.TASK_RETRIES_KEY, this.retryCount.get());
  }
509609
private synchronized void runTask(Task task) {
        if (taskThread == null) {
            taskThread = new TaskThread();
        }
        taskThread.runTask(task);
    }
326987
private synchronized void failReduce(TaskInProgress tip) {
    if (nonRunningReduces == null) {
      LOG.warn("Failed cache for reducers missing!! "
               + "Job details are missing.");
      return;
    }
    nonRunningReduces.add(0, tip);
  }
632928
void updateTaskStatuses(TaskTrackerStatus status) {
    String trackerName = status.getTrackerName();
    for (TaskStatus report : status.getTaskReports()) {
      report.setTaskTracker(trackerName);
      TaskAttemptID taskId = report.getTaskID();

      // Remove it from the expired task list
      if (report.getRunState() != TaskStatus.State.UNASSIGNED) {
        expireLaunchingTasks.removeTask(taskId);
      }

      JobInProgress job = getJob(taskId.getJobID());
      if (job == null) {
        // if job is not there in the cleanup list ... add it
        synchronized (trackerToJobsToCleanup) {
          Set<JobID> jobs = trackerToJobsToCleanup.get(trackerName);
          if (jobs == null) {
            jobs = new HashSet<JobID>();
            trackerToJobsToCleanup.put(trackerName, jobs);
          }
          jobs.add(taskId.getJobID());
        }
        continue;
      }

      if (!job.inited()) {
        // if job is not yet initialized ... kill the attempt
        synchronized (trackerToTasksToCleanup) {
          Set<TaskAttemptID> tasks = trackerToTasksToCleanup.get(trackerName);
          if (tasks == null) {
            tasks = new HashSet<TaskAttemptID>();
            trackerToTasksToCleanup.put(trackerName, tasks);
          }
          tasks.add(taskId);
        }
        continue;
      }

      TaskInProgress tip = taskidToTIPMap.get(taskId);
      // Check if the tip is known to the jobtracker. In case of a restarted
      // jt, some tasks might join in later
      if (tip != null) {
        // Update the job and inform the listeners if necessary
        JobStatus prevStatus = (JobStatus)job.getStatus().clone();
        // Clone TaskStatus object here, because JobInProgress
        // or TaskInProgress can modify this object and
        // the changes should not get reflected in TaskTrackerStatus.
        // An old TaskTrackerStatus is used later in countMapTasks, etc.
        job.updateTaskStatus(tip, (TaskStatus)report.clone());
        JobStatus newStatus = (JobStatus)job.getStatus().clone();

        // Update the listeners if an incomplete job completes
        if (prevStatus.getRunState() != newStatus.getRunState()) {
          JobStatusChangeEvent event =
            new JobStatusChangeEvent(job, EventType.RUN_STATE_CHANGED,
                                     prevStatus, newStatus);
          updateJobInProgressListeners(event);
        }
      } else {
        LOG.info("Serious problem.  While updating status, cannot find taskid "
                 + report.getTaskID());
      }

      // Process 'failed fetch' notifications
      List<TaskAttemptID> failedFetchMaps = report.getFetchFailedMaps();
      if (failedFetchMaps != null) {
        TaskAttemptID reportingAttempt = report.getTaskID();
        for (TaskAttemptID mapTaskId : failedFetchMaps) {
          TaskInProgress failedFetchMap = taskidToTIPMap.get(mapTaskId);

          if (failedFetchMap != null) {
            // Gather information about the map which has to be failed, if need be
            String failedFetchTrackerName = getAssignedTracker(mapTaskId);
            if (failedFetchTrackerName == null) {
              failedFetchTrackerName = "Lost task tracker";
            }
            ((JobInProgress)failedFetchMap.getJob()).fetchFailureNotification(
              reportingAttempt, failedFetchMap, mapTaskId, failedFetchTrackerName);
          }
        }
      }
    }
  }
645944
function tip(title, content, actions, type) {
  if (curTip) {
    curTip.close(() => {
      setTimeout(() => {
        AppContainer.remove(topViewDialogKey);
        setTimeout(() => {
          creatTip(title, content, actions);
        }, 0);
      }, 200);
    });
  } else {
    creatTip(title, content, actions, type);
  }
}
36782
@Override
    public void afterCompletion(int status) {
        if (status == Status.STATUS_COMMITTED) {
            Boolean previous = persistentExecutor.inMemoryTaskIds.put(taskId, Boolean.TRUE);
            if (previous == null) {
                long delay = expectedExecTime - new Date().getTime();
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(this, tc, "Schedule " + taskId + " for " + delay + "ms from now");
                persistentExecutor.scheduledExecutor.schedule(this, delay, TimeUnit.MILLISECONDS);
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(this, tc, "Found task " + taskId + " already scheduled");
            }
        }
    }
256968
protected void refreshTaskCountsAndWaitTime(TaskType type, long now) {
    TaskInProgress[] allTips = getTasks(type);
    int finishedTips = 0;
    int runningTips = 0;
    int runningTaskAttempts = 0;
    long totalWaitTime = 0;
    long jobStartTime = this.getStartTime();
    for (TaskInProgress tip : allTips) {
      if (tip.isComplete()) {
        finishedTips += 1;
      } else if(tip.isRunning()) {
        runningTaskAttempts += tip.getActiveTasks().size();
        runningTips += 1;
      }
      if (tip.getExecStartTime() > 0) {
        totalWaitTime += tip.getExecStartTime() - jobStartTime;
      } else {
        totalWaitTime += now - jobStartTime;
      }
    }
    if (TaskType.MAP == type) {
      totalMapWaitTime = totalWaitTime;
      runningMapTasks = runningTaskAttempts;
      neededMapTasks = numMapTasks - runningTips - finishedTips
          + neededSpeculativeMaps();
      pendingMapTasks = numMapTasks - runningTaskAttempts
          - failedMapTIPs - finishedMapTasks + speculativeMapTasks;
    } else {
      totalReduceWaitTime = totalWaitTime;
      runningReduceTasks = runningTaskAttempts;
      neededReduceTasks = numReduceTasks - runningTips - finishedTips
          + neededSpeculativeReduces();
      pendingReduceTasks = numReduceTasks - runningTaskAttempts
          - failedReduceTIPs - finishedReduceTasks + speculativeReduceTasks;
    }
  }
1034186
private void saveNewRequestForTip(TaskInProgress tip, ResourceRequest req) {
    requestToTipMap.put(req.getId(), tip);
    TaskContext context = taskToContextMap.get(tip);
    if (context == null) {
      context = new TaskContext(req);
    } else {
      context.resourceRequests.add(req);
    }
    taskToContextMap.put(tip, context);
  }
51178
public void cancel(TaskInProgress tip) {
    LOG.info("Canceling task "  + tip.getTask().getTaskID() + " of job " +
        tip.getTask().getJobID());
    // Cancel & remove the map completion finish thread for reduce tasks.
    if (!tip.getTask().isMapTask() && !tip.getTask().isTaskCleanupTask()) {
      if (!mapperWaitThreadMap.containsKey(tip)) {
        throw new RuntimeException("Mapper wait thread doesn't exist " +
            "for " + tip.getTask().getTaskID());
      }
      LOG.debug("Interrupting mapper wait thread for " +
          tip.getTask().getTaskID() + " job " +
          tip.getTask().getJobID());
      mapperWaitThreadMap.get(tip).interrupt();
      LOG.debug("Removing mapper wait thread for " +
          tip.getTask().getTaskID() + " job " + tip.getTask().getJobID());
      mapperWaitThreadMap.remove(tip);
    } else {
      LOG.debug(tip.getTask().getTaskID() + " is not a reduce task, so " +
          "not canceling mapper wait thread");
    }
    removeFromFinishingQueue(tip);
  }
771514
private synchronized void retireReduce(TaskInProgress tip) {
    if (runningReduces == null) {
      LOG.warn("Running list for reducers missing!! "
               + "Job details are missing.");
      return;
    }
    runningReduces.remove(tip);
  }
641890
public void completeTask(int taskId) {
		getResourceFactory().getApiResource("/task/" + taskId + "/complete")
				.entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post();
	}