Set the {@link TaskStatus} for the job identified by {@code jobId}.
776868
@Override
  public void setTaskStatus(final JobId jobId, final TaskStatus status)
      throws InterruptedException {
    log.debug("setting task status: {}", status);
    taskStatuses.put(jobId.toString(), status.toJsonBytes());
    if (historyWriter != null) {
      try {
        historyWriter.saveHistoryItem(status);
      } catch (Exception e) {
        // Log error here and keep going as saving task history is not critical.
        // This is to prevent bad data in the queue from screwing up the actually important Helios
        // agent operations.
        log.error("Error saving task status {} to ZooKeeper: {}", status, e);
      }
    }
    final TaskStatusEvent event = new TaskStatusEvent(status, System.currentTimeMillis(), agent);
    final byte[] message = event.toJsonBytes();
    for (final EventSender sender : eventSenders) {
      sender.send(taskStatusEventTopic, message);
    }
  }
131514
public void setJobStatesToNotify(java.util.Collection<String> jobStatesToNotify) {
        if (jobStatesToNotify == null) {
            this.jobStatesToNotify = null;
            return;
        }

        this.jobStatesToNotify = new java.util.ArrayList<String>(jobStatesToNotify);
    }
844199
public JobStatus readJobStatus(JobID jobId) {
    JobStatus jobStatus = null;
    
    if (null == jobId) {
      LOG.warn("Could not read job status for null jobId");
      return null;
    }
    
    if (active) {
      try {
        FSDataInputStream dataIn = getJobInfoFile(jobId);
        if (dataIn != null) {
          jobStatus = readJobStatus(dataIn);
          dataIn.close();
        }
      } catch (IOException ex) {
        LOG.warn("Could not read [" + jobId + "] job status : " + ex, ex);
      }
    }
    return jobStatus;
  }
1274533
public void updateStatus(JobStatus newStatus) {
    JobMonitor monitor = getJobMonitor(newStatus);
    monitor.updateStatus(newStatus);
  }
392140
public synchronized void notifyTaskCancellation(long jobId, int taskId) {
    Pair<Long, Integer> id = new Pair<>(jobId, taskId);
    TaskInfo.Builder taskInfo = mUnfinishedTasks.get(id);
    taskInfo.setStatus(Status.CANCELED);
    finishTask(id);
    LOG.info("Task {} for job {} canceled", taskId, jobId);
  }
609562
@Override
	public void updateJobStatus(long instanceId, JobStatus jobStatus) {
		logger.entering(CLASSNAME, "updateJobStatus", new Object[] {instanceId, jobStatus});
		if (logger.isLoggable(Level.FINE)) {
			logger.fine("Updating Job Status to: " + jobStatus.getBatchStatus());
		}
		Connection conn = null;
		PreparedStatement statement = null;
		try {
			conn = getConnection();
			statement = conn.prepareStatement("UPDATE jobstatus SET obj = ? WHERE id = ?");
			statement.setBytes(1, serializeObject(jobStatus));
			statement.setLong(2, instanceId);
			statement.executeUpdate();
		} catch (SQLException e) {
			throw new PersistenceException(e);
		} catch (IOException e) {
			throw new PersistenceException(e);
		} finally {
			cleanupConnection(conn, null, statement);
		}
		logger.exiting(CLASSNAME, "updateJobStatus");
	}
1161170
synchronized void setJobPriority(JobID jobId, JobPriority priority) {
    JobInProgress job = jobs.get(jobId);
    if (job != null) {
      synchronized (taskScheduler) {
        JobStatus oldStatus = (JobStatus)job.getStatus().clone();
        job.setPriority(priority);
        JobStatus newStatus = (JobStatus)job.getStatus().clone();
        JobStatusChangeEvent event =
          new JobStatusChangeEvent(job, EventType.PRIORITY_CHANGED, oldStatus,
                                   newStatus);
        updateJobInProgressListeners(event);
      }
    } else {
      LOG.warn("Trying to change the priority of an unknown job: " + jobId);
    }
  }
566770
public TaskMetricGroup addTask(
			final JobVertexID jobVertexId,
			final ExecutionAttemptID executionAttemptID,
			final String taskName,
			final int subtaskIndex,
			final int attemptNumber) {
		checkNotNull(jobVertexId);
		checkNotNull(executionAttemptID);
		checkNotNull(taskName);

		synchronized (this) {
			if (!isClosed()) {
				TaskMetricGroup prior = tasks.get(executionAttemptID);
				if (prior != null) {
					return prior;
				} else {
					TaskMetricGroup task = new TaskMetricGroup(
						registry,
						this,
						jobVertexId,
						executionAttemptID,
						taskName,
						subtaskIndex,
						attemptNumber);
					tasks.put(executionAttemptID, task);
					return task;
				}
			} else {
				return null;
			}
		}
	}
447587
@Override
    public BatchStatus getStatus(String snapshotId) throws SnapshotNotFoundException, SnapshotException {

        checkInitialized();
        JobExecution ex = getJobExecution(this.snapshotRepo.findByName(snapshotId));
        if (ex == null) {
            return BatchStatus.UNKNOWN;
        } else {
            return ex.getStatus();
        }
    }
1152658
public void setJobName (final String jobName)
  {
    if (jobName == null || jobName.trim ().length () == 0)
    {
      throw new IllegalArgumentException ("Job name cannot be null or empty.");
    }

    m_sJobName = jobName;
  }
619841
private <Q, R> void recordFinalStatus(JobIdentifier<Q, R> jobId, JobStatus<Q, R> jobStatus) {
        try {
            _jobStatusDAO.updateJobStatus(jobId, jobStatus);
        } catch (Exception e) {
            _log.error("Failed to record final status for job: [id={}, status={}]", jobId, jobStatus.getStatus(), e);
        }
    }
449932
public synchronized void notifyTaskFailure(long jobId, int taskId, String errorMessage) {
    Pair<Long, Integer> id = new Pair<>(jobId, taskId);
    TaskInfo.Builder taskInfo = mUnfinishedTasks.get(id);
    taskInfo.setStatus(Status.FAILED);
    taskInfo.setErrorMessage(errorMessage);
    finishTask(id);
    LOG.info("Task {} for job {} failed: {}", taskId, jobId, errorMessage);
  }
240480
private void updateTaskStatus(TaskTrackerInfo info, TaskStatus report) {
    TaskAttemptID taskId = report.getTaskID();

    // Here we want strict job id comparison.
    if (!this.jobId.equals(taskId.getJobID())) {
      LOG.warn("Task " + taskId + " belongs to unknown job "
          + taskId.getJobID());
      return;
    }

    TaskInProgress tip = taskLookupTable.getTIP(taskId);
    if (tip == null) {
      return;
    }
    TaskStatus status = tip.getTaskStatus(taskId);
    TaskStatus.State knownState = (status == null) ? null : status
        .getRunState();

    // Remove it from the expired task list
    if (report.getRunState() != TaskStatus.State.UNASSIGNED) {
      expireTasks.removeTask(taskId);
    }

    // Fallback heartbeats may claim that task is RUNNING, while it was killed
    if (report.getRunState() == TaskStatus.State.RUNNING
        && !TaskStatus.TERMINATING_STATES.contains(knownState)) {
      expireTasks.updateTask(taskId);
    }

    // Clone TaskStatus object here, because CoronaJobInProgress
    // or TaskInProgress can modify this object and
    // the changes should not get reflected in TaskTrackerStatus.
    // An old TaskTrackerStatus is used later in countMapTasks, etc.
    job.updateTaskStatus(tip, (TaskStatus) report.clone(), info);
  }
1155231
@Override
    public WSJobInstance updateJobInstanceAndExecutionWithInstanceStateAndBatchStatus(long instanceId, long executionId,
                                                                                      final InstanceState state, final BatchStatus batchStatus) {

        JobInstanceEntity retMe = null;

        //Update the JobInstance
        retMe = (JobInstanceEntity) persistenceManagerService.updateJobInstanceWithInstanceStateAndBatchStatus(instanceId, state, batchStatus, new Date());

        //Update the Job Execution Instance
        persistenceManagerService.updateJobExecutionAndInstanceOnStatusChange(executionId, batchStatus, new Date());

        return retMe;
    }
568428
@Override
  public TaskStatus getTaskStatus(final JobId jobId) {
    final byte[] data = taskStatuses.get(jobId.toString());
    if (data == null) {
      return null;
    }
    try {
      return parse(data, TaskStatus.class);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
302010
public void setJobs(java.util.Collection<String> jobs) {
        if (jobs == null) {
            this.jobs = null;
            return;
        }

        this.jobs = new java.util.ArrayList<String>(jobs);
    }
326432
public void onAzureBatchTaskStatus(final CloudTask cloudTask) {
    ResourceStatusEventImpl.Builder eventBuilder =
        ResourceStatusEventImpl.newBuilder()
            .setIdentifier(cloudTask.id())
            .setState(TaskStatusMapper.getReefTaskState(cloudTask))
            .setRuntimeName(RuntimeIdentifier.RUNTIME_NAME);

    if (TaskState.COMPLETED.equals(cloudTask.state())) {
      eventBuilder.setExitCode(cloudTask.executionInfo().exitCode());
    }

    this.reefEventHandlers.onResourceStatus(eventBuilder.build());
  }