use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class NoVncSecuredTargetResolverTest method mockSchedulerState.
@Before
public void mockSchedulerState() throws NotConnectedException, UnknownJobException, PermissionException {
JobState jobState = mock(JobState.class);
when(schedulerMock.getJobState("42")).thenReturn(jobState);
TaskState taskState = mock(TaskState.class);
when(taskState.getName()).thenReturn("remoteVisuTask");
TaskId taskId = mock(TaskId.class);
when(taskId.value()).thenReturn("1");
when(taskState.getId()).thenReturn(taskId);
when(jobState.getHMTasks()).thenReturn(Collections.singletonMap(taskId, taskState));
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class AbstractFunctCmdTest method cleanScheduler.
protected void cleanScheduler() throws NotConnectedException, PermissionException, UnknownJobException {
scheduler = RestFuncTHelper.getScheduler();
SchedulerState state = scheduler.getState();
System.out.println("Cleaning scheduler.");
List<JobState> aliveJobsStates = new ArrayList<>(state.getPendingJobs().size() + state.getRunningJobs().size());
aliveJobsStates.addAll(state.getPendingJobs());
aliveJobsStates.addAll(state.getRunningJobs());
List<JobState> finishedJobsStates = new ArrayList<>(state.getFinishedJobs().size());
finishedJobsStates.addAll(state.getFinishedJobs());
for (JobState jobState : aliveJobsStates) {
JobId jobId = jobState.getId();
try {
System.out.println("Killing job " + jobId);
scheduler.killJob(jobId);
} catch (Exception ignored) {
}
System.out.println("Removing killed job " + jobId);
scheduler.removeJob(jobId);
}
for (JobState jobState : finishedJobsStates) {
JobId jobId = jobState.getId();
System.out.println("Removing finished job " + jobId);
scheduler.removeJob(jobId);
}
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerClient method getJobState.
@Override
public JobState getJobState(String jobId) throws NotConnectedException, UnknownJobException, PermissionException {
JobState jobState = null;
try {
JobStateData jobStateData = restApi().listJobs(sid, jobId);
jobState = toJobState(jobStateData);
} catch (Exception e) {
throwUJEOrNCEOrPE(e);
}
return jobState;
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerClientTest method testJobSubmissionEventListener.
@Test(timeout = MAX_WAIT_TIME * 2)
public void testJobSubmissionEventListener() throws Exception {
ISchedulerClient client = clientInstance();
SchedulerEventListenerImpl listener = new SchedulerEventListenerImpl();
client.addEventListener(listener, true, SchedulerEvent.JOB_SUBMITTED, SchedulerEvent.USERS_UPDATE);
Job job = defaultJob();
JobId jobId = client.submit(job);
JobState submittedJob = listener.getSubmittedJob();
while (!submittedJob.getId().value().equals(jobId.value())) {
submittedJob = listener.getSubmittedJob();
}
UserIdentification userIdentification = listener.getLastUserUpdate();
assertTrue(userIdentification.getLastSubmitTime() != -1);
client.removeEventListener();
client.waitForJob(jobId, TimeUnit.SECONDS.toMillis(120));
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerEventBroadcaster method jobUpdatedFullDataEvent.
@Override
public void jobUpdatedFullDataEvent(JobState jobState) {
logEvent(jobState);
broadcast(new EventNotification(EventNotification.Action.JOB_FULL_DATA_UPDATED, SchedulerEvent.JOB_UPDATED.name(), jobState));
}
Aggregations