Search in sources :

Example 11 with UniqueID

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();
    }
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) RuntimeDataMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) SchedulerJMXHelper(org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) ExecutorService(java.util.concurrent.ExecutorService) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 12 with UniqueID

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");
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) Test(org.junit.Test)

Example 13 with UniqueID

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());
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID)

Example 14 with UniqueID

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;
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UniqueID(org.objectweb.proactive.core.UniqueID) ConnectToResourceManagerPermission(org.ow2.proactive.scheduler.permissions.ConnectToResourceManagerPermission) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl)

Example 15 with UniqueID

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();
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl)

Aggregations

UniqueID (org.objectweb.proactive.core.UniqueID)17 UserIdentificationImpl (org.ow2.proactive.scheduler.job.UserIdentificationImpl)8 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)4 Test (org.junit.Test)2 Client (org.ow2.proactive.resourcemanager.authentication.Client)2 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 TimeoutException (java.util.concurrent.TimeoutException)1 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)1 UserData (org.ow2.proactive.authentication.UserData)1 MethodCallPermission (org.ow2.proactive.permissions.MethodCallPermission)1 RMException (org.ow2.proactive.resourcemanager.exception.RMException)1 SchedulerState (org.ow2.proactive.scheduler.common.SchedulerState)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1 SchedulerJMXHelper (org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper)1 RuntimeDataMBeanImpl (org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl)1 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)1 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)1 ChangePolicyPermission (org.ow2.proactive.scheduler.permissions.ChangePolicyPermission)1 ChangePriorityPermission (org.ow2.proactive.scheduler.permissions.ChangePriorityPermission)1