use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class LiveJobs method restartAllInErrorTasks.
public Boolean restartAllInErrorTasks(JobId jobId) {
JobData jobData = lockJob(jobId);
if (jobData == null) {
return false;
}
try {
InternalJob job = jobData.job;
for (TaskState taskState : job.getTasks()) {
try {
restartInErrorTask(jobId, taskState.getName());
} catch (UnknownTaskException e) {
logger.error("", e);
jlogger.error(jobId, "", e);
tlogger.error(taskState.getId(), "", e);
}
}
setJobStatusToInErrorIfNotPaused(job);
dbManager.updateJobAndTasksState(job);
updateJobInSchedulerState(job, SchedulerEvent.JOB_RESTARTED_FROM_ERROR);
return Boolean.TRUE;
} finally {
jobData.unlock();
}
}
use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class LiveJobs method jobRecovered.
void jobRecovered(InternalJob job) {
jobs.put(job.getId(), new JobData(job));
for (InternalTask task : job.getITasks()) {
if (task.getStatus() == TaskStatus.RUNNING) {
logger.info("Recover task " + task.getId() + " (" + task.getName() + ") of job " + job.getId() + " (" + job.getName() + ")");
runningTasksData.put(TaskIdWrapper.wrap(task.getId()), new RunningTaskData(task, job.getOwner(), job.getCredentials(), task.getExecuterInformation().getLauncher()));
}
}
}
use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class LiveJobs method restartTaskOnNodeFailure.
TerminationData restartTaskOnNodeFailure(InternalTask task) {
JobData jobData = lockJob(task.getJobId());
if (jobData == null) {
return emptyResult(task.getId());
}
try {
TaskId taskId = task.getId();
if (task.getStatus() != TaskStatus.RUNNING) {
return emptyResult(taskId);
}
RunningTaskData taskData = runningTasksData.remove(TaskIdWrapper.wrap(taskId));
if (taskData == null) {
throw new IllegalStateException("Task " + task.getId() + " is not running.");
}
TerminationData result = TerminationData.newTerminationData();
result.addTaskData(jobData.job, taskData, TerminationData.TerminationStatus.NODEFAILED, null);
restartTaskOnNodeFailure(task, jobData, result);
return result;
} finally {
jobData.unlock();
}
}
use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class LiveJobs method lockJobsToSchedule.
Map<JobId, JobDescriptor> lockJobsToSchedule() {
TreeSet<JobPriority> prioritiesScheduled = new TreeSet<>();
TreeSet<JobPriority> prioritiesNotScheduled = new TreeSet<>();
Map<JobId, JobDescriptor> result = new HashMap<>();
for (Map.Entry<JobId, JobData> entry : jobs.entrySet()) {
JobData value = entry.getValue();
if (value.jobLock.tryLock()) {
InternalJob job = entry.getValue().job;
result.put(job.getId(), job.getJobDescriptor());
prioritiesScheduled.add(job.getPriority());
if (unlockIfConflict(prioritiesScheduled, prioritiesNotScheduled, result))
return new HashMap<>(0);
} else {
prioritiesNotScheduled.add(value.job.getPriority());
if (unlockIfConflict(prioritiesScheduled, prioritiesNotScheduled, result))
return new HashMap<>(0);
}
}
return result;
}
use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.
the class LiveJobs method killTask.
TerminationData killTask(JobId jobId, String taskName) throws UnknownJobException, UnknownTaskException {
JobData jobData = lockJob(jobId);
if (jobData == null) {
throw new UnknownJobException(jobId);
}
try {
InternalTask task = jobData.job.getTask(taskName);
tlogger.info(task.getId(), "killing task " + task.getId());
if (!task.getStatus().isTaskAlive()) {
tlogger.warn(task.getId(), "task isn't alive: " + task.getStatus());
return emptyResult(task.getId());
}
RunningTaskData taskData = runningTasksData.remove(TaskIdWrapper.wrap(task.getId()));
if (taskData == null) {
// the task is not in running state
taskData = new RunningTaskData(task, jobData.job.getOwner(), jobData.job.getCredentials(), null);
}
TaskResultImpl taskResult = taskResultCreator.getTaskResult(dbManager, jobData.job, task, new TaskAbortedException("The task has been manually killed."), new SimpleTaskLogs("", "The task has been manually killed."));
TerminationData terminationData = createAndFillTerminationData(taskResult, taskData, jobData.job, TerminationData.TerminationStatus.ABORTED);
if (onErrorPolicyInterpreter.requiresCancelJobOnError(task)) {
endJob(jobData, terminationData, task, taskResult, "The task has been manually killed. " + "You also ask to cancel the job in such a situation!", JobStatus.CANCELED);
} else {
terminateTask(jobData, task, true, taskResult, terminationData);
}
return terminationData;
} finally {
jobData.unlock();
}
}
Aggregations