use of org.ow2.proactive.scheduler.common.task.TaskInfo in project scheduling by ow2-proactive.
the class SchedulerDBManager method updateTaskData.
private int updateTaskData(final TaskState task, Session session) {
Query taskUpdateQuery = session.getNamedQuery("updateTaskData");
TaskInfo taskInfo = task.getTaskInfo();
return taskUpdateQuery.setParameter("taskStatus", taskInfo.getStatus()).setParameter("numberOfExecutionLeft", taskInfo.getNumberOfExecutionLeft()).setParameter("numberOfExecutionOnFailureLeft", taskInfo.getNumberOfExecutionOnFailureLeft()).setParameter("inErrorTime", taskInfo.getInErrorTime()).setParameter("taskId", taskId(task.getId())).executeUpdate();
}
use of org.ow2.proactive.scheduler.common.task.TaskInfo 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.common.task.TaskInfo in project scheduling by ow2-proactive.
the class SchedulerMonitorsHandler method addTaskEvent.
/**
* Add a Task Event to the list of occurred events (memorize it).
* @param event type of task event
* @param taskInfo TaskEvent object associated to Event
*/
private void addTaskEvent(SchedulerEvent event, TaskInfo taskInfo) {
TaskIdWrapper taskId = TaskIdWrapper.wrap(taskInfo.getTaskId());
List<TaskEventMonitor> taskEventMonitors = tasksEvents.get(taskId);
if (taskEventMonitors == null) {
taskEventMonitors = new ArrayList<>();
tasksEvents.put(taskId, taskEventMonitors);
}
taskEventMonitors.add(new TaskEventMonitor(event, taskInfo));
}
use of org.ow2.proactive.scheduler.common.task.TaskInfo in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method assertTaskInfoPage.
private void assertTaskInfoPage(Page<TaskInfo> page, TaskFilterCriteria criterias) {
List<TaskInfo> taskInfos = page.getList();
for (TaskInfo taskInfo : taskInfos) {
String taskStr = taskInfo.getName() + "," + taskInfo.getTaskId().getTag() + "," + String.valueOf(taskInfo.getFinishedTime()) + "," + taskInfo.getStatus();
System.out.println(taskStr);
String tag = criterias.getTag();
// tag
if (tag != null && "".compareTo(tag) != 0)
assertEquals("Tag is incorrect for task " + taskStr, tag, taskInfo.getTaskId().getTag());
// from
long from = criterias.getFrom();
if (from != 0)
assertEquals("startTime is incorrect", from, taskInfo.getStartTime());
// to
long to = criterias.getTo();
if (to != 0)
assertEquals("finishedTime is incorrect", to, taskInfo.getFinishedTime());
// pagination
int pageSize = criterias.getLimit() - criterias.getOffset();
if (pageSize > 0) {
assertTrue("Page size is incorrect", pageSize >= taskInfos.size());
}
// user
String user = criterias.getUser();
if (user != null && "".compareTo(user) != 0) {
assertEquals("user is incorrect", user, taskInfo.getJobInfo().getJobOwner());
}
// the corresponding criteria should be true
switch(taskInfo.getStatus()) {
case SUBMITTED:
case PENDING:
case NOT_STARTED:
assertTrue("Task status is incorrect", criterias.isPending());
break;
case PAUSED:
case RUNNING:
case WAITING_ON_ERROR:
case WAITING_ON_FAILURE:
assertTrue("Task status is incorrect", criterias.isRunning());
break;
case FAILED:
case NOT_RESTARTED:
case ABORTED:
case FAULTY:
case FINISHED:
case SKIPPED:
assertTrue("Task status is incorrect", criterias.isFinished());
break;
default:
fail("Incoherent task status");
}
}
}
use of org.ow2.proactive.scheduler.common.task.TaskInfo 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();
}
}
Aggregations