code: private synchronized void terminate(int jobTerminationState) {
      if(!tasksInited.get()) {
        //init could not be done, we just terminate directly.
        terminateJob(jobTerminationState);
        return;
      }
  
      if ((status.getRunState() == JobStatus.RUNNING) ||
           (status.getRunState() == JobStatus.PREP)) {
        LOG.info("Killing job '" + this.status.getJobID() + "'");
        if (jobTerminationState == JobStatus.FAILED) {
          if(jobFailed) {//reentrant
            return;
          }
          jobFailed = true;
        } else if (jobTerminationState == JobStatus.KILLED) {
          if(jobKilled) {//reentrant
            return;
          }
          jobKilled = true;
        }
        // clear all unclean tasks
        clearUncleanTasks();
        //
        // kill all TIPs.
        //
        for (int i = 0; i < setup.length; i++) {
          setup[i].kill();
        }
        for (int i = 0; i < maps.length; i++) {
          maps[i].kill();
        }
        for (int i = 0; i < reduces.length; i++) {
          reduces[i].kill();
        }
  
        if (!jobSetupCleanupNeeded) {
          terminateJob(jobTerminationState);
        }
      }
    }
docs: Terminate the job and all its component tasks.
  Calling this will lead to marking the job as failed/killed. Cleanup
  tip will be launched. If the job has not inited, it will directly call
  terminateJob as there is no need to launch cleanup tip.
  This method is reentrant.
  @param jobTerminationState job termination state