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;
}
}
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;
}
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);
}
}
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;
}
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();
}
}
Aggregations