Search in sources :

Example 6 with RMMonitoring

use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring 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)2 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)2 Client (org.ow2.proactive.resourcemanager.authentication.Client)2 NodeState (org.ow2.proactive.resourcemanager.common.NodeState)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 TimerTask (java.util.TimerTask)1 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1 ProActiveException (org.objectweb.proactive.core.ProActiveException)1 StubObject (org.objectweb.proactive.core.mop.StubObject)1 Node (org.objectweb.proactive.core.node.Node)1 NodeException (org.objectweb.proactive.core.node.NodeException)1 RMAuthenticationImpl (org.ow2.proactive.resourcemanager.authentication.RMAuthenticationImpl)1 NodesCleaner (org.ow2.proactive.resourcemanager.cleaning.NodesCleaner)1 RMEvent (org.ow2.proactive.resourcemanager.common.event.RMEvent)1 NotConnectedException (org.ow2.proactive.resourcemanager.exception.NotConnectedException)1 RMException (org.ow2.proactive.resourcemanager.exception.RMException)1 RMMonitoringImpl (org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl)1 RMNodeConfigurator (org.ow2.proactive.resourcemanager.nodesource.RMNodeConfigurator)1 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)1 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)1