Search in sources :

Example 6 with ClientJobState

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

the class SchedulerFrontendStateTest method getIdentifiedJobTest.

@Test
public void getIdentifiedJobTest() throws Exception {
    SchedulerJMXHelper mockJMX = mock(SchedulerJMXHelper.class);
    when(mockJMX.getSchedulerRuntimeMBean()).thenReturn(new RuntimeDataMBeanImpl(null));
    SchedulerStateImpl<ClientJobState> schedulerStateImpl = new SchedulerStateImpl<>();
    JobIdImpl jobId = new JobIdImpl(1234L, "job name");
    ClientJobState jobState = mock(ClientJobState.class);
    when(jobState.getId()).thenReturn(jobId);
    schedulerStateImpl.setFinishedJobs(new Vector(Lists.newArrayList(jobState)));
    final SchedulerFrontendState schedulerFrontendState = new SchedulerFrontendState(schedulerStateImpl, mockJMX);
    assertEquals(schedulerFrontendState.getIdentifiedJob(jobId).getJobId(), (jobId));
}
Also used : SchedulerJMXHelper(org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper) RuntimeDataMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Vector(java.util.Vector) Test(org.junit.Test)

Example 7 with ClientJobState

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

the class SchedulerFrontendState method jobUpdatedFullData.

@Override
public synchronized void jobUpdatedFullData(JobState jobstate) {
    ClientJobState storedJobState = new ClientJobState(jobstate);
    dispatchJobUpdatedFullData(storedJobState);
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

Example 8 with ClientJobState

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

the class SchedulerFrontendState method recover.

/**
 * Called to recover the front end state. This method may have to rebuild
 * the different list of userIdentification and job/user association.
 */
private void recover(SchedulerStateImpl sState) {
    Vector<ClientJobState> pendingJobs = sState.getPendingJobs();
    Vector<ClientJobState> runningJobs = sState.getRunningJobs();
    Vector<ClientJobState> finishedJobs = sState.getFinishedJobs();
    // default state = started
    Set<JobState> jobStates = new HashSet<>(pendingJobs.size() + runningJobs.size() + finishedJobs.size());
    if (logger.isInfoEnabled()) {
        logger.info("#Pending jobs: " + pendingJobs.size() + " #Running jobs: " + runningJobs.size() + " #Finished jobs: " + finishedJobs.size());
    }
    for (ClientJobState js : pendingJobs) {
        prepare(jobStates, js, false);
    }
    for (ClientJobState js : runningJobs) {
        prepare(jobStates, js, false);
    }
    for (ClientJobState js : finishedJobs) {
        prepare(jobStates, js, true);
    }
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) HashSet(java.util.HashSet)

Example 9 with ClientJobState

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

the class SchedulerFrontendState method jobStateUpdated.

@Override
public synchronized void jobStateUpdated(String owner, NotificationData<JobInfo> notification) {
    ClientJobState js = jobsMap.get(notification.getData().getJobId());
    synchronized (js) {
        js.update(notification.getData());
        switch(notification.getEventType()) {
            case JOB_PENDING_TO_RUNNING:
                sState.pendingToRunning(js);
                break;
            case JOB_PAUSED:
            case JOB_IN_ERROR:
            case JOB_RESUMED:
            case JOB_RESTARTED_FROM_ERROR:
            case JOB_CHANGE_PRIORITY:
            case TASK_REPLICATED:
            case TASK_SKIPPED:
                break;
            case JOB_PENDING_TO_FINISHED:
                sState.pendingToFinished(js);
                // set this job finished, user can get its result
                jobs.get(notification.getData().getJobId()).setFinished(true);
                break;
            case JOB_RUNNING_TO_FINISHED:
                sState.runningToFinished(js);
                // set this job finished, user can get its result
                jobs.get(notification.getData().getJobId()).setFinished(true);
                break;
            case JOB_REMOVE_FINISHED:
                // removing jobs from the global list : this job is no more managed
                sState.removeFinished(js);
                jobsMap.remove(js.getId());
                jobs.remove(notification.getData().getJobId());
                logger.debug("HOUSEKEEPING removed the finished job " + js.getId() + " from the SchedulerFrontEndState");
                break;
            default:
                logger.warn("**WARNING** - Unconsistent update type received from Scheduler Core : " + notification.getEventType());
                return;
        }
        dispatchJobStateUpdated(owner, notification);
        new JobEmailNotification(js, notification).checkAndSend();
    }
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

Example 10 with ClientJobState

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

the class SchedulerFrontendState method prepare.

/**
 * Prepare the job in the frontend
 *
 * @param jobStates
 *            a temporary set of jobs
 * @param js
 *            the current job to be prepared
 * @param finished
 *            if the job is finished or not
 */
private void prepare(Set<JobState> jobStates, ClientJobState js, boolean finished) {
    jobStates.add(js);
    UserIdentificationImpl uIdent = new UserIdentificationImpl(js.getOwner());
    IdentifiedJob ij = new IdentifiedJob(js.getId(), uIdent, js.getGenericInformation());
    jobs.put(js.getId(), ij);
    jobsMap.put(js.getId(), js);
    ij.setFinished(finished);
}
Also used : IdentifiedJob(org.ow2.proactive.scheduler.job.IdentifiedJob) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl)

Aggregations

ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)10 Test (org.junit.Test)4 JobState (org.ow2.proactive.scheduler.common.job.JobState)2 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)2 SchedulerJMXHelper (org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper)2 RuntimeDataMBeanImpl (org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl)2 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)2 UserIdentificationImpl (org.ow2.proactive.scheduler.job.UserIdentificationImpl)2 ClientTaskState (org.ow2.proactive.scheduler.task.ClientTaskState)2 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Vector (java.util.Vector)1 ExecutionException (java.util.concurrent.ExecutionException)1