use of org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper in project scheduling by ow2-proactive.
the class SchedulerFrontendStateTest method session_removal_should_not_throw_concurrent_modification_exception.
// SCHEDULING-2242
@Test
public void session_removal_should_not_throw_concurrent_modification_exception() throws Exception {
PASchedulerProperties.SCHEDULER_USER_SESSION_TIME.updateProperty("1");
SchedulerJMXHelper mockJMX = mock(SchedulerJMXHelper.class);
when(mockJMX.getSchedulerRuntimeMBean()).thenReturn(new RuntimeDataMBeanImpl(null));
final SchedulerFrontendState schedulerFrontendState = new SchedulerFrontendState(new SchedulerStateImpl<ClientJobState>(), mockJMX);
// create a bunch of active sessions, they will be removed in 1s
for (int i = 0; i < 100; i++) {
UserIdentificationImpl identification = new UserIdentificationImpl("john");
identification.setHostName("localhost");
schedulerFrontendState.connect(new UniqueID("abc" + i), identification, null);
}
// use the FrontendState continuously to query the active sessions
ExecutorService executor = Executors.newFixedThreadPool(1);
Future<Object> noException = executor.submit(new Callable<Object>() {
@Override
public Object call() throws Exception {
for (; ; ) {
schedulerFrontendState.getUsers();
}
}
});
try {
noException.get(2, TimeUnit.SECONDS);
} catch (ExecutionException e) {
fail("Should exit with timeout exception " + e.getMessage());
} catch (TimeoutException e) {
// expected timeout exception after two seconds
} finally {
executor.shutdownNow();
}
}
use of org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper 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));
}
Aggregations