Beispiel #1
0
 /**
  * Attempt to kill a running task. If the task has not started running, it will not start. If it's
  * already running, a kill request will be sent to it.
  *
  * <p>The AM will be informed about the task kill.
  */
 public void killTask() {
   if (!isCompleted.get()) {
     if (!killInvoked.getAndSet(true)) {
       synchronized (this) {
         LOG.info(
             "Kill task requested for id={}, taskRunnerSetup={}",
             taskSpec.getTaskAttemptID(),
             (taskRunner != null));
         if (taskRunner != null) {
           killtimerWatch.start();
           LOG.info("Issuing kill to task {}", taskSpec.getTaskAttemptID());
           boolean killed = taskRunner.killTask();
           if (killed) {
             // Sending a kill message to the AM right here. Don't need to wait for the task to
             // complete.
             LOG.info(
                 "Kill request for task {} completed. Informing AM", taskSpec.getTaskAttemptID());
             reportTaskKilled();
           } else {
             LOG.info(
                 "Kill request for task {} did not complete because the task is already complete",
                 taskSpec.getTaskAttemptID());
           }
           shouldRunTask = false;
         } else {
           // If the task hasn't started, and it is killed - report back to the AM that the task
           // has been killed.
           LOG.debug("Reporting taskKilled for non-started fragment {}", getRequestId());
           reportTaskKilled();
         }
         if (!isStarted.get()) {
           // If the task hasn't started - inform about fragment completion immediately. It's
           // possible for
           // the callable to never run.
           fragmentCompletionHanler.fragmentComplete(fragmentInfo);
           this.amReporter.unregisterTask(request.getAmHost(), request.getAmPort());
         }
       }
     } else {
       // This should not happen.
       LOG.warn(
           "Ignoring kill request for task {} since a previous kill request was processed",
           taskSpec.getTaskAttemptID());
     }
   } else {
     LOG.info(
         "Ignoring kill request for task {} since it's already complete",
         taskSpec.getTaskAttemptID());
   }
 }