Search in sources :

Example 6 with UniqueID

use of org.objectweb.proactive.core.UniqueID in project scheduling by ow2-proactive.

the class SchedulerFrontendState method clearListeners.

/*
     * ###########################################################################################
     */
/*                                                                                             */
/*
     * ################################## LISTENER DISPATCHER ####################################
     */
/*                                                                                             */
/*
     * ###########################################################################################
     */
/**
 * Clear every dirty listeners that are no more responding
 */
private void clearListeners() {
    Set<UniqueID> toRemove;
    synchronized (dirtyList) {
        if (dirtyList.isEmpty()) {
            return;
        }
        toRemove = new HashSet<>(dirtyList);
        dirtyList.clear();
    }
    for (UniqueID uId : toRemove) {
        disconnect(uId);
    }
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID)

Example 7 with UniqueID

use of org.objectweb.proactive.core.UniqueID 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 8 with UniqueID

use of org.objectweb.proactive.core.UniqueID 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 9 with UniqueID

use of org.objectweb.proactive.core.UniqueID in project scheduling by ow2-proactive.

the class SchedulerFrontendState method addEventListener.

synchronized SchedulerState addEventListener(SchedulerEventListener sel, boolean myEventsOnly, boolean getCurrentState, SchedulerEvent... events) throws NotConnectedException, PermissionException {
    // checking permissions
    ListeningUser uIdent = checkPermissionReturningListeningUser("addEventListener", YOU_DO_NOT_HAVE_PERMISSION_TO_ADD_A_LISTENER);
    // check if listener is not null
    if (sel == null) {
        String msg = "Scheduler listener must be not null";
        logger.info(msg);
        throw new IllegalArgumentException(msg);
    }
    // check if the listener is a reified remote object
    if (!MOP.isReifiedObject(sel)) {
        String msg = "Scheduler listener must be a remote object";
        logger.info(msg);
        throw new IllegalArgumentException(msg);
    }
    // get the scheduler State
    SchedulerState currentState = null;
    if (getCurrentState) {
        // check get state permission is checked in getState method
        currentState = getState(myEventsOnly);
    } else {
        // check get state permission
        handleOnlyMyJobsPermission(myEventsOnly, uIdent.getUser(), YOU_DO_NOT_HAVE_PERMISSION_TO_ADD_A_LISTENER);
    }
    // prepare user for receiving events
    uIdent.getUser().setUserEvents(events);
    // set if the user wants to get its events only or every events
    uIdent.getUser().setMyEventsOnly(myEventsOnly);
    // add the listener to the list of listener for this user.
    UniqueID id = PAActiveObject.getContext().getCurrentRequest().getSourceBodyID();
    uIdent.setListener(new ClientRequestHandler(this, id, sel));
    // cancel timer for this user : session is now managed by events
    uIdent.getUser().getSession().cancel();
    // return to the user
    return currentState;
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState)

Example 10 with UniqueID

use of org.objectweb.proactive.core.UniqueID in project scheduling by ow2-proactive.

the class RMMonitoringImpl method addRMEventListener.

/**
 * Register a new Resource manager listener.
 * Way to a monitor object to ask at RMMonitoring to throw
 * RM events to it.
 * @param stub a listener object which implements {@link RMEventListener}
 * interface.
 * @param events list of wanted events that must be received.
 * @return RMInitialState snapshot of RM's current state : nodes and node sources.
 */
public RMInitialState addRMEventListener(RMEventListener stub, RMEventType... events) {
    UniqueID id = PAActiveObject.getContext().getCurrentRequest().getSourceBodyID();
    logger.debug("Adding the RM listener for " + id.shortString());
    synchronized (dispatchers) {
        Client client = null;
        synchronized (RMCore.clients) {
            client = RMCore.clients.get(id);
        }
        if (client == null) {
            throw new IllegalArgumentException("Unknown client " + id.shortString());
        }
        EventDispatcher eventDispatcher = null;
        if (stub instanceof RMGroupEventListener) {
            eventDispatcher = new GroupEventDispatcher(client, stub, events);
        } else {
            eventDispatcher = new EventDispatcher(client, stub, events);
        }
        this.dispatchers.put(id, eventDispatcher);
        RMInitialState rmInitialState = rmcore.getRMInitialState();
        eventDispatcher.setCounter(rmInitialState.getLatestCounter());
        return rmInitialState;
    }
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) Client(org.ow2.proactive.resourcemanager.authentication.Client)

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