code: public synchronized void failJob(JobInProgress job) {
      if (null == job) {
        LOG.info("Fail on null job is not valid");
        return;
      }
  
      JobStatus prevStatus = (JobStatus)job.getStatus().clone();
      LOG.info("Failing job " + job.getJobID());
      job.fail();
  
      // Inform the listeners if the job state has changed
      JobStatus newStatus = (JobStatus)job.getStatus().clone();
      if (prevStatus.getRunState() != newStatus.getRunState()) {
        JobStatusChangeEvent event =
          new JobStatusChangeEvent(job, EventType.RUN_STATE_CHANGED, prevStatus,
              newStatus);
        updateJobInProgressListeners(event);
      }
    }
docs: Fail a job and inform the listeners. Other components in the framework
  should use this to fail a job.