code: private void jobStateChanged(JobStatusChangeEvent event, QueueInfo qi) {
      JobInProgress job = event.getJobInProgress();
      JobSchedulingInfo oldJobStateInfo = 
        new JobSchedulingInfo(event.getOldStatus());
      // Check if the ordering of the job has changed
      // For now priority and start-time can change the job ordering
      if (event.getEventType() == EventType.PRIORITY_CHANGED 
          || event.getEventType() == EventType.START_TIME_CHANGED) {
        // Make a priority change
        reorderJobs(job, oldJobStateInfo, qi);
      } else if (event.getEventType() == EventType.RUN_STATE_CHANGED) {
        // Check if the job is complete
        int runState = job.getStatus().getRunState();
        if (runState == JobStatus.SUCCEEDED
            || runState == JobStatus.FAILED
            || runState == JobStatus.KILLED) {
          jobCompleted(job, oldJobStateInfo, qi);
        } else if (runState == JobStatus.RUNNING) {
          makeJobRunning(job, oldJobStateInfo, qi);
        }
      }
    }
docs: Update the scheduler as job's state has changed