Search in sources :

Example 31 with TaskInfo

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();
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) Query(org.hibernate.Query)

Example 32 with TaskInfo

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;
}
Also used : TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl)

Example 33 with 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));
}
Also used : TaskIdWrapper(org.ow2.proactive.utils.TaskIdWrapper)

Example 34 with 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");
        }
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo)

Example 35 with TaskInfo

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();
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl)

Aggregations

TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)15 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)14 JobId (org.ow2.proactive.scheduler.common.job.JobId)10 Test (org.junit.Test)8 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)7 JobState (org.ow2.proactive.scheduler.common.job.JobState)7 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)6 ArrayList (java.util.ArrayList)5 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)5 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)4 TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)4 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)4 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)4 File (java.io.File)3 TaskAbortedException (org.ow2.proactive.scheduler.common.exception.TaskAbortedException)3 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)3 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)3 TaskInfoData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)3 Page (org.ow2.proactive.scheduler.common.Page)2