use of org.ow2.proactive.scheduler.task.TaskInfoImpl in project scheduling by ow2-proactive.
the class InternalTask method replicate.
/**
* {@inheritDoc}
*/
@Override
public TaskState replicate() throws ExecutableCreationException {
/*
* this implementation deep copies everything using serialization. however the new
* InternalTask cannot be strictly identical and we have to handle the following special
* cases:
*
* - ExecutableContainer is transient and not copied during serialization. It needs to be
* manually copied, and added to the InternalTask replica
*
* - Using the TaskInfo of _this_ gives us a FINISHED task, need to explicitely create a new
* clean one.
*
* - InternalTask dependencies need to be nulled as they contain references to other
* InternalTasks, and will be rewritten later anyway
*
* - Most of the objects down the object graph contain Hibernate @Id fields. If all those
* fields are not set to 0 when inserting the object in DB, insertion will fail.
*
* - Collections are mapped to specific Hibernate internal collections at runtime, which
* contain references to the @Id fields mentionned above. They need to be reset too.
*/
InternalTask replicatedTask = null;
// ExecutableContainer replicatedContainer = null;
try {
// Deep copy of the InternalTask using proactive serialization
replicatedTask = (InternalTask) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(this);
} catch (Throwable t) {
throw new ExecutableCreationException("Failed to serialize task", t);
}
replicatedTask.internalJob = internalJob;
// internalTasksDependencies contain references to other InternalTasks, it needs to be removed.
// anyway, dependencies for the new task will not be the same as the original
replicatedTask.internalTasksDependencies = null;
// the taskinfo needs to be cleaned so that we don't tag this task as finished
TaskId repId = replicatedTask.taskInfo.getTaskId();
replicatedTask.taskInfo = new TaskInfoImpl();
// we only need this id for the HashSet comparisons...
replicatedTask.taskInfo.setTaskId(repId);
replicatedTask.taskInfo.setNumberOfExecutionLeft(getMaxNumberOfExecution());
replicatedTask.taskInfo.setNumberOfExecutionOnFailureLeft(getMaxNumberOfExecutionOnFailure());
replicatedTask.setReplicatedFrom(this);
// The next DB.update(InternalJob) will take care of it
return replicatedTask;
}
use of org.ow2.proactive.scheduler.task.TaskInfoImpl in project scheduling by ow2-proactive.
the class SchedulingService method getProgressAndPingTaskNode.
void getProgressAndPingTaskNode(RunningTaskData taskData) {
if (!jobs.canPingTask(taskData) || taskData.getPingAttempts() > PASchedulerProperties.SCHEDULER_NODE_PING_ATTEMPTS.getValueAsInt()) {
return;
}
InternalTask task = taskData.getTask();
try {
// (2)
int progress = taskData.getLauncher().getProgress();
// get previous inside td
if (progress != task.getProgress()) {
// (1)
task.setProgress(progress);
// if progress != previously set progress (0 by default) -> update
listener.taskStateUpdated(taskData.getUser(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_PROGRESS, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
}
} catch (Throwable t) {
tlogger.debug(task.getId(), "TaskLauncher is not accessible, checking if the node can be reached.", t);
pingTaskNodeAndInitiateRestart(task);
}
}
use of org.ow2.proactive.scheduler.task.TaskInfoImpl in project scheduling by ow2-proactive.
the class TaskData method toTaskInfo.
public TaskInfo toTaskInfo() {
JobIdImpl jobId = new JobIdImpl(getJobData().getId(), getJobData().getJobName());
TaskInfoImpl taskInfo = createTaskInfo(jobId);
return taskInfo;
}
use of org.ow2.proactive.scheduler.task.TaskInfoImpl 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.task.TaskInfoImpl 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);
}
}
Aggregations