use of org.ow2.proactive.scheduler.job.InternalJob 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.job.InternalJob in project scheduling by ow2-proactive.
the class LiveJobs method unpauseAll.
void unpauseAll() {
for (JobId jobId : jobs.keySet()) {
JobData jobData = lockJob(jobId);
if (jobData != null) {
try {
InternalJob job = jobData.job;
if (job.getStatus() == JobStatus.PAUSED) {
job.setUnPause();
dbManager.updateJobAndTasksState(job);
updateJobInSchedulerState(job, SchedulerEvent.JOB_RESUMED);
}
} finally {
jobData.unlock();
}
}
}
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class LiveJobs method resumeJob.
boolean resumeJob(JobId jobId) {
JobData jobData = lockJob(jobId);
if (jobData == null) {
return false;
}
try {
InternalJob job = jobData.job;
Set<TaskId> updatedTasks = job.setUnPause();
if (!updatedTasks.isEmpty()) {
jlogger.info(jobId, "has just been resumed.");
dbManager.updateJobAndTasksState(job);
updateTasksInSchedulerState(job, updatedTasks);
}
// update tasks events list and send it to front-end
updateJobInSchedulerState(job, SchedulerEvent.JOB_RESUMED);
return !updatedTasks.isEmpty();
} finally {
jobData.unlock();
}
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class LiveJobs method suspendTaskOnError.
private void suspendTaskOnError(JobData jobData, InternalTask task, long taskDuration) {
InternalJob job = jobData.job;
job.setInErrorTime(System.currentTimeMillis());
job.setTaskPausedOnError(task);
setJobStatusToInErrorIfNotPaused(job);
job.incrementNumberOfInErrorTasksBy(1);
task.setInErrorTime(task.getStartTime() + taskDuration);
dbManager.updateJobAndTasksState(job);
updateTaskPausedOnerrorState(job, task.getId());
updateJobInSchedulerState(job, SchedulerEvent.JOB_IN_ERROR);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class LiveJobs method restartTaskOnNodeFailure.
private void restartTaskOnNodeFailure(InternalTask task, JobData jobData, TerminationData terminationData) {
final String errorMsg = "An error has occurred due to a node failure and the maximum amount of retries property has been reached.";
task.setProgress(0);
task.decreaseNumberOfExecutionOnFailureLeft();
tlogger.info(task.getId(), "number of retry on failure left " + task.getNumberOfExecutionOnFailureLeft());
InternalJob job = jobData.job;
if (task.getNumberOfExecutionOnFailureLeft() > 0) {
task.setStatus(TaskStatus.WAITING_ON_FAILURE);
job.newWaitingTask();
listener.taskStateUpdated(job.getOwner(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_WAITING_FOR_RESTART, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
job.reStartTask(task);
dbManager.taskRestarted(job, task, null);
tlogger.info(task.getId(), " is waiting for restart");
} else {
job.incrementNumberOfFailedTasksBy(1);
endJob(jobData, terminationData, task, null, errorMsg, JobStatus.FAILED);
}
}
Aggregations