public void retrieveJobStatus(PigJob job) {
    TempletonApi.JobInfo info;
    try {
      info = UserLocalObjects.getTempletonApi(context).checkJob(job.getJobId());
    } catch (IOException e) {
      LOG.warn(String.format("IO Exception: %s", e));
      return;
    }

    if (info.status != null && (info.status.containsKey("runState"))) {
      //TODO: retrieve from RM
      Long time = System.currentTimeMillis() / 1000L;
      Long currentDuration = time - job.getDateStarted();
      int runState = ((Double) info.status.get("runState")).intValue();
      boolean isStatusChanged = false;
      switch (runState) {
        case RUN_STATE_KILLED:
          LOG.debug(String.format("Job KILLED: %s", job.getJobId()));
          isStatusChanged = !job.getStatus().equals(PigJob.PIG_JOB_STATE_KILLED);
          job.setStatus(PigJob.PIG_JOB_STATE_KILLED);
          break;
        case RUN_STATE_FAILED:
          LOG.debug(String.format("Job FAILED: %s", job.getJobId()));
          isStatusChanged = !job.getStatus().equals(PigJob.PIG_JOB_STATE_FAILED);
          job.setStatus(PigJob.PIG_JOB_STATE_FAILED);
          break;
        case RUN_STATE_PREP:
        case RUN_STATE_RUNNING:
          isStatusChanged = !job.getStatus().equals(PigJob.PIG_JOB_STATE_RUNNING);
          job.setStatus(PigJob.PIG_JOB_STATE_RUNNING);
          break;
        case RUN_STATE_SUCCEEDED:
          LOG.debug(String.format("Job COMPLETED: %s", job.getJobId()));
          isStatusChanged = !job.getStatus().equals(PigJob.PIG_JOB_STATE_COMPLETED);
          job.setStatus(PigJob.PIG_JOB_STATE_COMPLETED);
          break;
        default:
          LOG.debug(String.format("Job in unknown state: %s", job.getJobId()));
          isStatusChanged = !job.getStatus().equals(PigJob.PIG_JOB_STATE_UNKNOWN);
          job.setStatus(PigJob.PIG_JOB_STATE_UNKNOWN);
          break;
      }
      if (isStatusChanged) {
        job.setDuration(currentDuration);
      }
    }
    Pattern pattern = Pattern.compile("\\d+");
    Matcher matcher = null;
    if (info.percentComplete != null) {
      matcher = pattern.matcher(info.percentComplete);
    }
    if (matcher != null && matcher.find()) {
      job.setPercentComplete(Integer.valueOf(matcher.group()));
    } else {
      job.setPercentComplete(null);
    }
    save(job);
  }
Get job status
@param job job object
contrib/views/pig/src/main/java/org/apache/ambari/view/pig/resources/jobs/JobResourceManager.java