use of org.objectweb.proactive.core.UniqueID 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.objectweb.proactive.core.UniqueID in project scheduling by ow2-proactive.
the class SchedulerFrontendTest method testConnection.
/**
* Related to issue #1849.
* <p>
* https://github.com/ow2-proactive/scheduling/issues/1849
*/
@Test
public void testConnection() throws KeyException, AlreadyConnectedException {
schedulerFrontend.connect(new UniqueID(), new UserIdentificationImpl("admin"), null);
Mockito.verify(spacesSupport, times(1)).registerUserSpace("admin");
}
use of org.objectweb.proactive.core.UniqueID in project scheduling by ow2-proactive.
the class SchedulerFrontendState method removeEventListener.
synchronized void removeEventListener() throws NotConnectedException, PermissionException {
// Remove the listener on that user designated by its given UniqueID,
// then renew its user session as it is no more managed by the listener.
UniqueID id = checkAccess();
ListeningUser uIdent = identifications.get(id);
uIdent.clearListener();
// recreate the session for this user which is no more managed by
// listener
renewUserSession(id, uIdent.getUser());
}
use of org.objectweb.proactive.core.UniqueID in project scheduling by ow2-proactive.
the class SchedulerFrontendState method checkLinkResourceManager.
synchronized void checkLinkResourceManager() throws NotConnectedException, PermissionException {
UniqueID id = checkAccess();
UserIdentificationImpl ident = identifications.get(id).getUser();
// renew session for this user
renewUserSession(id, ident);
try {
ident.checkPermission(new ConnectToResourceManagerPermission(), ident.getUsername() + " does not have permissions to change RM in the scheduler");
} catch (PermissionException ex) {
logger.info(ex.getMessage());
throw ex;
}
}
use of org.objectweb.proactive.core.UniqueID in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getCurrentUser.
public String getCurrentUser() throws NotConnectedException {
UniqueID id = checkAccess();
UserIdentificationImpl ident = identifications.get(id).getUser();
// renew session for this user
renewUserSession(id, ident);
return ident.getUsername();
}
Aggregations