Search in sources :

Example 71 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo 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(), null);
        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);
        ((JobInfoImpl) job.getJobInfo()).setPreciousTasks(job.getPreciousTasksFinished());
        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(), job.getGenericInformation(), job.getCredentials());
        }
        task.setInErrorTime(-1);
        boolean jobUpdated = false;
        if (job.getNumberOfInErrorTasks() == 0) {
            job.setInErrorTime(-1);
            jobUpdated = true;
        }
        // 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);
        } else if (jobUpdated) {
            listener.jobStateUpdated(job.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_UPDATED, 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) NotificationData(org.ow2.proactive.scheduler.common.NotificationData)

Example 72 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.

the class LiveJobs method jobSubmitted.

void jobSubmitted(InternalJob job) {
    job.prepareTasks();
    job.submitAction();
    dbManager.newJobSubmitted(job);
    ClientJobState clientJobState = new ClientJobState(job);
    jobs.put(job.getId(), new JobData(job));
    listener.jobSubmitted(clientJobState);
    if (job.getParentId() != null) {
        // If a job has a parent, it means that the parent job children count has been increased.
        // accordingly, we need to send a JOB_UPDATED notification of the parent
        JobId parentJobId = JobIdImpl.makeJobId(job.getParentId().toString());
        JobData parentJobData = jobs.get(parentJobId);
        if (parentJobData != null) {
            // the parent job is alive, we load it from memory
            InternalJob parentJob = parentJobData.job;
            ((JobInfoImpl) parentJob.getJobInfo()).setChildrenCount(parentJob.getJobInfo().getChildrenCount() + 1);
            listener.jobStateUpdated(parentJob.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_UPDATED, new JobInfoImpl((JobInfoImpl) parentJob.getJobInfo())));
        } else {
            // the parent job is terminated, we load it from the db
            List<InternalJob> internalJobs = dbManager.loadInternalJob(job.getParentId());
            if (!internalJobs.isEmpty()) {
                InternalJob parentJob = internalJobs.get(0);
                listener.jobStateUpdated(parentJob.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_UPDATED, new JobInfoImpl((JobInfoImpl) parentJob.getJobInfo())));
            }
        }
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 73 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo 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);
    // merge task map result to job map result
    job.getResultMap().putAll(result.getResultMap());
    ChangedTasksInfo changesInfo = job.terminateTask(errorOccurred, taskId, listener, result.getAction(), result);
    ((JobInfoImpl) job.getJobInfo()).setPreciousTasks(job.getPreciousTasksFinished());
    boolean jobFinished = job.isFinished();
    // update job info if it is terminated
    if (jobFinished) {
        // terminating job
        job.terminate();
        // Cleaning job signals
        cleanJobSignals(job.getId());
        jlogger.debug(job.getId(), "terminated");
        terminationData.addJobToTerminate(job.getId(), job.getGenericInformation(), job.getCredentials());
        jobs.remove(job.getId());
    }
    task.setTaskResult(result);
    // 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 74 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.

the class SchedulerFrontend method getJobInfo.

@Override
@ImmediateService
public JobInfo getJobInfo(String jobId) throws UnknownJobException, NotConnectedException, PermissionException {
    JobInfo jobInfo = getJobState(JobIdImpl.makeJobId(jobId)).getJobInfo();
    insertJobSignals(jobInfo);
    insertVisualization(jobInfo);
    filterVariablesAndGenericInfo(jobInfo);
    return jobInfo;
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 75 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.

the class SchedulerFrontend method insertVisualization.

private JobInfo insertVisualization(JobInfo jobInfo) {
    String jobid = jobInfo.getJobId().value();
    if (checkJobPermissionMethod(jobid, "enableRemoteVisualization")) {
        try {
            JobInfo jobInfoState = frontendState.getJobState(jobInfo.getJobId()).getJobInfo();
            jobInfo.setVisualizationConnectionStrings(jobInfoState.getVisualizationConnectionStrings());
            jobInfo.setVisualizationIcons(jobInfoState.getVisualizationIcons());
        } catch (PermissionException e) {
            logger.debug("Could not add visualization info for job " + jobInfo.getJobId(), e);
        } catch (UnknownJobException | NotConnectedException e1) {
            logger.warn("Could not add visualization info for job " + jobInfo.getJobId(), e1);
        }
    }
    return jobInfo;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException)

Aggregations

JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)47 JobId (org.ow2.proactive.scheduler.common.job.JobId)29 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)12 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)12 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)11 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)10 JobState (org.ow2.proactive.scheduler.common.job.JobState)10 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)10 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)9 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)9 Job (org.ow2.proactive.scheduler.common.job.Job)8 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)8 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 File (java.io.File)7 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)7 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)7 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)7 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)7 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)7