Search in sources :

Example 6 with UserIdentificationImpl

use of org.ow2.proactive.scheduler.job.UserIdentificationImpl in project scheduling by ow2-proactive.

the class SchedulerFrontendState method checkChangePolicy.

synchronized void checkChangePolicy() throws NotConnectedException, PermissionException {
    UniqueID id = checkAccess();
    UserIdentificationImpl ident = identifications.get(id).getUser();
    // renew session for this user
    renewUserSession(id, ident);
    try {
        ident.checkPermission(new ChangePolicyPermission(), ident.getUsername() + " does not have permissions to change the policy of 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) ChangePolicyPermission(org.ow2.proactive.scheduler.permissions.ChangePolicyPermission) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl)

Example 7 with UserIdentificationImpl

use of org.ow2.proactive.scheduler.job.UserIdentificationImpl in project scheduling by ow2-proactive.

the class SchedulerFrontendState method createJob.

synchronized InternalJob createJob(Job userJob, UserIdentificationImpl ident) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
    UniqueID id = checkAccess();
    // get the internal job.
    InternalJob job = InternalJobFactory.createJob(userJob, this.credentials.get(id));
    // setting job informations
    if (job.getTasks().size() == 0) {
        String msg = "Job " + job.getId().value() + " contains no task. You need to insert at least one task before submitting job";
        logger.info(msg);
        throw new JobCreationException(msg);
    }
    // job.
    try {
        ident.checkPermission(new ChangePriorityPermission(job.getPriority().ordinal()), ident.getUsername() + " does not have rights to set job priority " + job.getPriority());
    } catch (PermissionException ex) {
        logger.info(ex.getMessage());
        throw ex;
    }
    // setting the job properties
    job.setOwner(ident.getUsername());
    return job;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UniqueID(org.objectweb.proactive.core.UniqueID) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) ChangePriorityPermission(org.ow2.proactive.scheduler.permissions.ChangePriorityPermission)

Example 8 with UserIdentificationImpl

use of org.ow2.proactive.scheduler.job.UserIdentificationImpl in project scheduling by ow2-proactive.

the class SchedulerFrontendState method jobSubmitted.

synchronized void jobSubmitted(InternalJob job, UserIdentificationImpl ident) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
    // put the job inside the frontend management list
    jobs.put(job.getId(), new IdentifiedJob(job.getId(), ident, job.getGenericInformation()));
    // increase number of submit for this user
    ident.addSubmit();
    // send update user event
    usersUpdated(new NotificationData<UserIdentification>(SchedulerEvent.USERS_UPDATE, ident));
    jlogger.info(job.getId(), "submitted: name '" + job.getName() + "', tasks '" + job.getTotalNumberOfTasks() + "', owner '" + job.getOwner() + "'");
    try {
        jlogger.info(job.getId(), job.display());
    } catch (Exception e) {
        jlogger.error(job.getId(), "Error while displaying the job :", e);
    }
}
Also used : IdentifiedJob(org.ow2.proactive.scheduler.job.IdentifiedJob) UserIdentification(org.ow2.proactive.scheduler.common.job.UserIdentification) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException)

Example 9 with UserIdentificationImpl

use of org.ow2.proactive.scheduler.job.UserIdentificationImpl in project scheduling by ow2-proactive.

the class SchedulerAuthentication method login.

/**
 * {@inheritDoc}
 */
public Scheduler login(Credentials cred) throws LoginException, AlreadyConnectedException {
    Subject subject = authenticate(cred);
    UserNamePrincipal unPrincipal = subject.getPrincipals(UserNamePrincipal.class).iterator().next();
    String user = unPrincipal.getName();
    logger.info("user : " + user);
    // add this user to the scheduler front-end
    UserIdentificationImpl ident = new UserIdentificationImpl(user, subject);
    ident.setHostName(getSenderHostName());
    this.frontend.connect(PAActiveObject.getContext().getCurrentRequest().getSourceBodyID(), ident, cred);
    try {
        // return the stub on Scheduler interface to keep avoid using server class on client side
        return PAActiveObject.lookupActive(Scheduler.class, PAActiveObject.getUrl(frontend));
    } catch (ActiveObjectCreationException e) {
        rethrowSchedulerStubException(e);
    } catch (IOException e) {
        rethrowSchedulerStubException(e);
    }
    return null;
}
Also used : UserNamePrincipal(org.ow2.proactive.authentication.principals.UserNamePrincipal) IOException(java.io.IOException) Subject(javax.security.auth.Subject) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException)

Example 10 with UserIdentificationImpl

use of org.ow2.proactive.scheduler.job.UserIdentificationImpl 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)

Aggregations

UserIdentificationImpl (org.ow2.proactive.scheduler.job.UserIdentificationImpl)16 UniqueID (org.objectweb.proactive.core.UniqueID)9 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)6 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)3 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)3 IOException (java.io.IOException)2 Test (org.junit.Test)2 ImmediateService (org.objectweb.proactive.annotation.ImmediateService)2 AlreadyConnectedException (org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)2 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)2 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)2 IdentifiedJob (org.ow2.proactive.scheduler.job.IdentifiedJob)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 ChangePriorityPermission (org.ow2.proactive.scheduler.permissions.ChangePriorityPermission)2 KeyException (java.security.KeyException)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1