use of org.ow2.proactive.scheduler.common.NotificationData in project scheduling by ow2-proactive.
the class JobRemoveHandler method call.
@Override
public Boolean call() {
long start = 0;
if (logger.isInfoEnabled()) {
start = System.currentTimeMillis();
logger.info("Removing job " + jobId);
}
SchedulerDBManager dbManager = service.getInfrastructure().getDBManager();
List<InternalJob> jobs = dbManager.loadJobWithTasksIfNotRemoved(jobId);
TerminationData terminationData;
// if the context is not in sync with the database
if (jobs.size() != 1) {
terminationData = service.getJobs().removeJob(jobId);
} else {
// if the job was already finished we just remove it from the context
if (isInFinishedState(jobs.get(0))) {
terminationData = service.getJobs().removeJob(jobId);
} else {
terminationData = service.getJobs().killJob(jobId);
}
}
service.submitTerminationDataHandler(terminationData);
// if the job doesn't exist in the DB anymore we can stop here
if (jobs.size() != 1) {
return false;
}
jobs.get(0).setRemovedTime(System.currentTimeMillis());
boolean removeFromDb = PASchedulerProperties.JOB_REMOVE_FROM_DB.getValueAsBoolean();
dbManager.removeJob(jobId, jobs.get(0).getRemovedTime(), removeFromDb);
ServerJobAndTaskLogs.remove(jobId);
if (logger.isInfoEnabled()) {
logger.info("Job " + jobId + " removed in " + (System.currentTimeMillis() - start) + "ms");
}
// send event to front-end
service.getListener().jobStateUpdated(jobs.get(0).getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_REMOVE_FINISHED, new JobInfoImpl((JobInfoImpl) jobs.get(0).getJobInfo())));
service.wakeUpSchedulingThread();
return true;
}
use of org.ow2.proactive.scheduler.common.NotificationData in project scheduling by ow2-proactive.
the class LiveJobs method finishInErrorTask.
TerminationData finishInErrorTask(JobId jobId, String taskName) throws UnknownTaskException, UnknownJobException {
JobData jobData = lockJob(jobId);
if (jobData == null) {
throw new UnknownJobException(jobId);
}
InternalJob job = jobData.job;
try {
InternalTask task = job.getTask(taskName);
if (task == null) {
throw new UnknownTaskException(taskName);
}
TaskId taskId = task.getId();
if (task.getStatus() != TaskStatus.IN_ERROR) {
tlogger.info(task.getId(), "Task must be in state IN_ERROR: " + task.getStatus());
return emptyResult(task.getId());
}
TaskResultImpl taskResult = taskResultCreator.getTaskResult(dbManager, job, task);
RunningTaskData data = new RunningTaskData(task, job.getOwner(), job.getCredentials(), task.getExecuterInformation().getLauncher());
TerminationData terminationData = TerminationData.newTerminationData();
terminationData.addTaskData(job, data, TerminationData.TerminationStatus.ABORTED, taskResult);
tlogger.debug(taskId, "result added to job " + job.getId());
// to be done before terminating the task, once terminated it is not
// running anymore..
ChangedTasksInfo changesInfo = job.finishInErrorTask(taskId, taskResult, listener);
boolean jobFinished = job.isFinished();
// update job info if it is terminated
if (jobFinished) {
// terminating job
job.terminate();
jlogger.debug(job.getId(), "terminated");
jobs.remove(job.getId());
terminationData.addJobToTerminate(job.getId());
}
// Update database
if (taskResult.getAction() != null) {
dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, taskResult);
} else {
dbManager.updateAfterTaskFinished(job, task, taskResult);
}
// send event
listener.taskStateUpdated(job.getOwner(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_IN_ERROR_TO_FINISHED, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
// if this job is finished (every task have finished)
jlogger.info(job.getId(), "finished tasks " + job.getNumberOfFinishedTasks() + ", total tasks " + job.getTotalNumberOfTasks() + ", finished " + jobFinished);
if (jobFinished) {
// send event to client
listener.jobStateUpdated(job.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, new JobInfoImpl((JobInfoImpl) job.getJobInfo())));
listener.jobUpdatedFullData(job);
}
return terminationData;
} finally {
jobData.unlock();
}
}
use of org.ow2.proactive.scheduler.common.NotificationData in project scheduling by ow2-proactive.
the class LiveJobs method terminateTask.
private void terminateTask(JobData jobData, InternalTask task, boolean errorOccurred, TaskResultImpl result, TerminationData terminationData) {
InternalJob job = jobData.job;
TaskId taskId = task.getId();
tlogger.debug(taskId, "result added to job " + job.getId());
// to be done before terminating the task, once terminated it is not
// running anymore..
job.getRunningTaskDescriptor(taskId);
ChangedTasksInfo changesInfo = job.terminateTask(errorOccurred, taskId, listener, result.getAction(), result);
boolean jobFinished = job.isFinished();
// update job info if it is terminated
if (jobFinished) {
// terminating job
job.terminate();
jlogger.debug(job.getId(), "terminated");
terminationData.addJobToTerminate(job.getId());
}
// Update database
if (result.getAction() != null) {
dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
} else {
dbManager.updateAfterTaskFinished(job, task, result);
}
// send event
listener.taskStateUpdated(job.getOwner(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_RUNNING_TO_FINISHED, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
// if this job is finished (every task have finished)
jlogger.info(job.getId(), "finished tasks " + job.getNumberOfFinishedTasks() + ", total tasks " + job.getTotalNumberOfTasks() + ", finished " + jobFinished);
if (jobFinished) {
// send event to client
listener.jobStateUpdated(job.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, new JobInfoImpl((JobInfoImpl) job.getJobInfo())));
listener.jobUpdatedFullData(job);
}
}
use of org.ow2.proactive.scheduler.common.NotificationData in project scheduling by ow2-proactive.
the class LiveJobs method updateTaskPausedOnerrorState.
private void updateTaskPausedOnerrorState(InternalJob job, TaskId taskToUpdate) {
try {
InternalTask t = job.getTask(taskToUpdate);
TaskInfo ti = new TaskInfoImpl((TaskInfoImpl) t.getTaskInfo());
listener.taskStateUpdated(job.getOwner(), new NotificationData<>(SchedulerEvent.TASK_IN_ERROR, ti));
} catch (UnknownTaskException e) {
logger.error(e);
}
}
use of org.ow2.proactive.scheduler.common.NotificationData in project scheduling by ow2-proactive.
the class LiveJobs method restartTaskOnError.
private void restartTaskOnError(JobData jobData, InternalTask task, TaskStatus status, TaskResultImpl result, long waitTime, TerminationData terminationData) {
InternalJob job = jobData.job;
tlogger.info(task.getId(), "node Exclusion : restart mode is '" + task.getRestartTaskOnError() + "'");
if (task.getRestartTaskOnError().equals(RestartMode.ELSEWHERE)) {
task.setNodeExclusion(task.getExecuterInformation().getNodes());
}
task.setStatus(status);
job.newWaitingTask();
dbManager.updateAfterTaskFinished(job, task, result);
listener.taskStateUpdated(job.getOwner(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_WAITING_FOR_RESTART, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
terminationData.addRestartData(task.getId(), waitTime);
logger.info("END restartTaskOnError");
}
Aggregations