use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.
the class AbstractFunctCmdTest method submitJob.
protected JobId submitJob(String filename, JobStatus waitForStatus) throws Exception {
File jobFile = new File(this.getClass().getResource("config/" + filename).toURI());
WorkflowSubmitter submitter = new WorkflowSubmitter(scheduler);
JobId id = submitter.submit(jobFile, new HashMap<String, String>());
waitJobState(id, waitForStatus, 500000);
return id;
}
use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.
the class LiveJobs method endJob.
private void endJob(JobData jobData, TerminationData terminationData, InternalTask task, TaskResultImpl taskResult, String errorMsg, JobStatus jobStatus) {
JobId jobId = jobData.job.getId();
jobs.remove(jobId);
terminationData.addJobToTerminate(jobId);
InternalJob job = jobData.job;
SchedulerEvent event;
if (job.getStatus() == JobStatus.PENDING) {
event = SchedulerEvent.JOB_PENDING_TO_FINISHED;
} else {
event = SchedulerEvent.JOB_RUNNING_TO_FINISHED;
}
if (task != null) {
jlogger.info(job.getId(), "ending request caused by task " + task.getId());
} else {
jlogger.info(job.getId(), "ending request");
}
for (Iterator<RunningTaskData> i = runningTasksData.values().iterator(); i.hasNext(); ) {
RunningTaskData taskData = i.next();
if (taskData.getTask().getJobId().equals(jobId)) {
i.remove();
// remove previous read progress
taskData.getTask().setProgress(0);
terminationData.addTaskData(job, taskData, TerminationData.TerminationStatus.ABORTED, taskResult);
}
}
// if job has been killed
if (jobStatus == JobStatus.KILLED) {
Set<TaskId> tasksToUpdate = job.failed(null, jobStatus);
dbManager.updateAfterJobKilled(job, tasksToUpdate);
updateTasksInSchedulerState(job, tasksToUpdate);
} else {
// finished state (failed/canceled)
if (jobStatus != JobStatus.FINISHED) {
Set<TaskId> tasksToUpdate = job.failed(task.getId(), jobStatus);
// store the exception into jobResult / To prevent from empty
// task result (when job canceled), create one
boolean noResult = (jobStatus == JobStatus.CANCELED && taskResult == null);
if (jobStatus == JobStatus.FAILED || noResult) {
taskResult = new TaskResultImpl(task.getId(), new Exception(errorMsg), new SimpleTaskLogs("", errorMsg), -1);
}
dbManager.updateAfterJobFailed(job, task, taskResult, tasksToUpdate);
updateTasksInSchedulerState(job, tasksToUpdate);
}
}
// update job and tasks events list and send it to front-end
updateJobInSchedulerState(job, event);
jlogger.info(job.getId(), "finished (" + jobStatus + ")");
}
use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.
the class InternalJob method failed.
/**
* Failed this job due to the given task failure or job has been killed
*
* @param taskId the task that has been the cause to failure. Can be null if
* the job has been killed
* @param jobStatus type of the failure on this job. (failed/canceled/killed)
*/
public Set<TaskId> failed(TaskId taskId, JobStatus jobStatus) {
if (jobStatus != JobStatus.KILLED) {
InternalTask descriptor = tasks.get(taskId);
if (descriptor.getStartTime() > 0) {
descriptor.setFinishedTime(System.currentTimeMillis());
setNumberOfFinishedTasks(getNumberOfFinishedTasks() + 1);
if (descriptor.getExecutionDuration() < 0) {
descriptor.setExecutionDuration(descriptor.getFinishedTime() - descriptor.getStartTime());
}
}
descriptor.setStatus((jobStatus == JobStatus.FAILED) ? TaskStatus.FAILED : TaskStatus.FAULTY);
// terminate this job descriptor
getJobDescriptor().failed();
}
// set the new status of the job
setFinishedTime(System.currentTimeMillis());
setNumberOfPendingTasks(0);
setNumberOfRunningTasks(0);
setStatus(jobStatus);
// creating list of status
Set<TaskId> updatedTasks = new HashSet<>();
for (InternalTask td : tasks.values()) {
if (!td.getId().equals(taskId)) {
if (td.getStatus() == TaskStatus.RUNNING) {
td.setStatus(TaskStatus.ABORTED);
td.setFinishedTime(System.currentTimeMillis());
if (td.getStartTime() > 0 && td.getExecutionDuration() < 0) {
td.setExecutionDuration(td.getFinishedTime() - td.getStartTime());
}
updatedTasks.add(td.getId());
} else if (td.getStatus() == TaskStatus.WAITING_ON_ERROR || td.getStatus() == TaskStatus.WAITING_ON_FAILURE) {
td.setStatus(TaskStatus.NOT_RESTARTED);
updatedTasks.add(td.getId());
} else if (td.getStatus() != TaskStatus.FINISHED && td.getStatus() != TaskStatus.FAILED && td.getStatus() != TaskStatus.FAULTY && td.getStatus() != TaskStatus.SKIPPED) {
td.setStatus(TaskStatus.NOT_STARTED);
updatedTasks.add(td.getId());
}
}
}
terminateTaskDataSpaceApplications();
return updatedTasks;
}
use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.
the class RecoveredSchedulerStateTest method createJob.
public InternalJob createJob(JobStatus jobStatus, int id) {
InternalTaskFlowJob job = new InternalTaskFlowJob("MyJob", JobPriority.HIGH, OnTaskError.CANCEL_JOB, "Description");
InternalScriptTask internalScriptTask = new InternalScriptTask(job);
job.addTasks(ImmutableList.<InternalTask>of(internalScriptTask));
job.setId(JobIdImpl.makeJobId("" + id));
JobInfoImpl jobInfo = (JobInfoImpl) job.getJobInfo();
jobInfo.setStatus(jobStatus);
return job;
}
use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithMixedJobs.
@Test
public void testRecoverWithMixedJobs() throws Exception {
ImmutableList<JobStatus> jobStatuses = ImmutableList.of(JobStatus.CANCELED, JobStatus.FAILED, JobStatus.FINISHED, JobStatus.KILLED, JobStatus.PAUSED, JobStatus.PENDING, JobStatus.RUNNING, JobStatus.STALLED);
ImmutableList<TaskStatus> taskStatuses = ImmutableList.of(TaskStatus.ABORTED, TaskStatus.FAILED, TaskStatus.FINISHED, TaskStatus.ABORTED, TaskStatus.PAUSED, TaskStatus.PENDING, TaskStatus.RUNNING, TaskStatus.SUBMITTED);
List<InternalJob> jobs = new ArrayList<>(jobStatuses.size());
for (int i = 0; i < jobStatuses.size(); i++) {
InternalJob job = createJob(jobStatuses.get(i));
jobs.add(job);
changeTasksState(job, taskStatuses.get(i));
}
RecoveredSchedulerState recoveredState = new Scenario(jobs).execute();
assertThat(recoveredState.getFinishedJobs()).hasSize(4);
assertThat(recoveredState.getPendingJobs()).hasSize(2);
assertThat(recoveredState.getRunningJobs()).hasSize(2);
}
Aggregations