Search in sources :

Example 1 with RMEventListener

use of org.ow2.proactive.resourcemanager.frontend.RMEventListener 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)1 Client (org.ow2.proactive.resourcemanager.authentication.Client)1