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));
}
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);
}
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);
}
}
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();
}
}
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);
}
Aggregations