Search in sources :

Example 1 with SchedulerListenerExposer

use of scalabilityTests.framework.listeners.SchedulerListenerExposer in project scheduling by ow2-proactive.

the class AbstractSchedulerUser method registerListener.

public void registerListener(boolean getInitialState, boolean myEventsOnly, String listenerClazzName) throws SchedulerException, ProActiveException {
    try {
        if (this.scheduler == null)
            throw new IllegalStateException("The user is not connected to the Scheduler yet. " + "Consider calling the connectToScheduler() method first");
        SchedulerEventListener schedulerListener = createEventListener(listenerClazzName);
        logger.trace("Trying to expose the listener as a remote object");
        slExposer = new SchedulerListenerExposer(schedulerListener);
        SchedulerEventListener schedulerListenerRemoteRef = slExposer.createRemoteReference();
        logger.trace("Trying to register the listener to the Scheduler");
        // for the moment, listens only to the Jobs-related events
        SchedulerState initialState = scheduler.addEventListener(schedulerListenerRemoteRef, myEventsOnly, getInitialState, // job-related events
        SchedulerEvent.JOB_SUBMITTED, SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_PENDING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_PAUSED, SchedulerEvent.JOB_RESUMED, SchedulerEvent.JOB_RESTARTED_FROM_ERROR, SchedulerEvent.JOB_CHANGE_PRIORITY, // task-related events
        SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.TASK_WAITING_FOR_RESTART, SchedulerEvent.USERS_UPDATE, // Scheduler state related events
        SchedulerEvent.FROZEN, SchedulerEvent.RESUMED, SchedulerEvent.SHUTDOWN, SchedulerEvent.SHUTTING_DOWN, SchedulerEvent.STARTED, SchedulerEvent.STOPPED, SchedulerEvent.KILLED);
        if (getInitialState) {
            logger.info("Initial state of the scheduler is: " + initialState);
        }
    } catch (ClassNotFoundException e) {
        throw new IllegalArgumentException("Class " + listenerClazzName + " is not available on this SchedulerUser's side", e);
    } catch (InstantiationException e) {
        throw new IllegalArgumentException("Cannot instantiate listener of type " + listenerClazzName, e);
    } catch (IllegalAccessException e) {
        throw new IllegalArgumentException("Cannot instantiate listener of type " + listenerClazzName, e);
    }
}
Also used : SchedulerListenerExposer(scalabilityTests.framework.listeners.SchedulerListenerExposer) SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState) SchedulerEventListener(org.ow2.proactive.scheduler.common.SchedulerEventListener)

Aggregations

SchedulerEventListener (org.ow2.proactive.scheduler.common.SchedulerEventListener)1 SchedulerState (org.ow2.proactive.scheduler.common.SchedulerState)1 SchedulerListenerExposer (scalabilityTests.framework.listeners.SchedulerListenerExposer)1