Search in sources :

Example 21 with ClientJobState

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

Aggregations

ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)19 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)6 Test (org.junit.Test)5 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 AlreadyConnectedException (org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException)3 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)3 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)3 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)3 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)3 SchedulerJMXHelper (org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper)3 RuntimeDataMBeanImpl (org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl)3 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)3 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)3 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)3 Vector (java.util.Vector)2 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)2 JobState (org.ow2.proactive.scheduler.common.job.JobState)2 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)2