Search in sources :

Example 96 with TaskResultImpl

use of org.ow2.proactive.scheduler.task.TaskResultImpl 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)

Example 97 with TaskResultImpl

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

Example 98 with TaskResultImpl

use of org.ow2.proactive.scheduler.task.TaskResultImpl 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");
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl)

Aggregations

TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)73 Test (org.junit.Test)70 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)32 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)30 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)26 SimpleScript (org.ow2.proactive.scripting.SimpleScript)26 TaskScript (org.ow2.proactive.scripting.TaskScript)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)25 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)25 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)22 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)21 JobId (org.ow2.proactive.scheduler.common.job.JobId)16 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)16 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)15 HashMap (java.util.HashMap)13 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)13 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)12 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)11 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)10