Search in sources :

Example 1 with RMMonitoring

use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring in project scheduling by ow2-proactive.

the class RMCore method initActivity.

/**
 * Initialization part of the RMCore active object.
 * Create RM's active objects and the default static Node Source named
 * {@link RMConstants#DEFAULT_STATIC_SOURCE_NAME}. Finally, it throws the RM
 * started event.
 *
 * @param body the active object's body.
 */
public void initActivity(Body body) {
    if (logger.isDebugEnabled()) {
        logger.debug("RMCore start : initActivity");
    }
    try {
        // setting up the policy
        logger.debug("Setting up the resource manager security policy");
        ClientsPolicy.init();
        StubObject rmCoreStub = PAActiveObject.getStubOnThis();
        PAActiveObject.registerByName(rmCoreStub, RMConstants.NAME_ACTIVE_OBJECT_RMCORE);
        dbManager = RMDBManager.getInstance();
        if (logger.isDebugEnabled()) {
            logger.debug("Creating RMAuthentication active object");
        }
        authentication = (RMAuthenticationImpl) PAActiveObject.newActive(RMAuthenticationImpl.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        if (logger.isDebugEnabled()) {
            logger.debug("Creating RMMonitoring active object");
        }
        // Boot the JMX infrastructure
        this.jmxHelper.boot(authentication);
        monitoring = (RMMonitoringImpl) PAActiveObject.newActive(RMMonitoringImpl.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        if (logger.isDebugEnabled()) {
            logger.debug("Creating SelectionManager active object");
        }
        selectionManager = (SelectionManager) PAActiveObject.newActive(ProbablisticSelectionManager.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        if (logger.isDebugEnabled()) {
            logger.debug("Creating ClientPinger active object");
        }
        clientPinger = (ClientPinger) PAActiveObject.newActive(ClientPinger.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        if (logger.isDebugEnabled()) {
            logger.debug("Creating NodeCleaner active object");
        }
        nodesCleaner = (NodesCleaner) PAActiveObject.newActive(NodesCleaner.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        topologyManager = new TopologyManager();
        nodeConfigurator = (RMNodeConfigurator) PAActiveObject.newActive(RMNodeConfigurator.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        // adding shutdown hook
        final RMCore rmcoreStub = (RMCore) rmCoreStub;
        Runtime.getRuntime().addShutdownHook(new Thread() {

            @Override
            public void run() {
                if (!toShutDown) {
                    rmcoreStub.shutdown(true);
                }
                synchronized (nodeRM) {
                    if (!shutedDown) {
                        try {
                            // wait for rmcore shutdown (5 min at most)
                            nodeRM.wait(5 * 60 * 60 * 1000);
                        } catch (InterruptedException e) {
                            logger.warn("shutdown hook interrupted", e);
                        }
                    }
                }
            }
        });
        // Creating RM started event
        this.monitoring.rmEvent(new RMEvent(RMEventType.STARTED));
        authentication.setActivated(true);
        clientPinger.ping();
        initiateRecoveryIfRequired();
    } catch (ActiveObjectCreationException e) {
        logger.error("", e);
    } catch (NodeException e) {
        logger.error("", e);
    } catch (ProActiveException e) {
        logger.error("", e);
    } catch (ClassNotFoundException e) {
        logger.error("", e);
    } finally {
        signalRMCoreIsInitialized();
    }
    if (logger.isDebugEnabled()) {
        logger.debug("RMCore end: initActivity");
    }
}
Also used : ProbablisticSelectionManager(org.ow2.proactive.resourcemanager.selection.statistics.ProbablisticSelectionManager) ClientPinger(org.ow2.proactive.resourcemanager.utils.ClientPinger) RMMonitoringImpl(org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl) NodeException(org.objectweb.proactive.core.node.NodeException) ProActiveException(org.objectweb.proactive.core.ProActiveException) RMAuthenticationImpl(org.ow2.proactive.resourcemanager.authentication.RMAuthenticationImpl) StubObject(org.objectweb.proactive.core.mop.StubObject) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) NodesCleaner(org.ow2.proactive.resourcemanager.cleaning.NodesCleaner) TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) RMEvent(org.ow2.proactive.resourcemanager.common.event.RMEvent) RMNodeConfigurator(org.ow2.proactive.resourcemanager.nodesource.RMNodeConfigurator)

Example 2 with RMMonitoring

use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring in project scheduling by ow2-proactive.

the class RMMonitoringImpl method removeRMEventListener.

/**
 * Removes a listener from RMMonitoring. Only listener itself must call this method
 */
public void removeRMEventListener() throws RMException {
    UniqueID id = PAActiveObject.getContext().getCurrentRequest().getSourceBodyID();
    String shortId = id.shortString();
    if (removeRMEventListener(id)) {
        logger.debug("Removing the RM listener for " + shortId);
    } else {
        throw new RMException("Unknown listener found: " + shortId);
    }
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 3 with RMMonitoring

use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring in project scheduling by ow2-proactive.

the class RestartDownNodesPolicy method activate.

/**
 * Activates static policy. Register a listener in RMMonitoring
 */
@Override
public BooleanWrapper activate() {
    acquireAllNodes();
    timer.schedule(new TimerTask() {

        @Override
        public void run() {
            int numberOfNodesToDeploy = 0;
            for (Node downNode : nodeSource.getDownNodes()) {
                String nodeUrl = downNode.getNodeInformation().getURL();
                logger.info("Removing down node " + nodeUrl);
                BooleanWrapper removed = nodeSource.getRMCore().removeNode(nodeUrl, true);
                if (removed.getBooleanValue()) {
                    logger.info("Down node removed " + nodeUrl);
                    numberOfNodesToDeploy++;
                }
            }
            for (RMDeployingNode lostNode : nodeSource.getDeployingAndLostNodes()) {
                if (!lostNode.isLost()) {
                    continue;
                }
                String nodeUrl = lostNode.getNodeURL();
                logger.info("Removing lost node " + nodeUrl);
                BooleanWrapper removed = nodeSource.getRMCore().removeNode(nodeUrl, true);
                if (removed.getBooleanValue()) {
                    logger.info("Lost node removed " + nodeUrl);
                    numberOfNodesToDeploy++;
                }
            }
            if (numberOfNodesToDeploy > 0) {
                logger.info("Acquiring " + numberOfNodesToDeploy + " nodes");
                acquireNodes(numberOfNodesToDeploy);
            }
        }
    }, checkNodeStateEach, checkNodeStateEach);
    return new BooleanWrapper(true);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) TimerTask(java.util.TimerTask) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) Node(org.objectweb.proactive.core.node.Node) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)

Example 4 with RMMonitoring

use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring in project scheduling by ow2-proactive.

the class RMCore method internalSetFree.

/**
 * Change the state of the node to free, after a Task has been completed by the specified node.
 * The node passed as parameter is moved to the list of nodes which are eligible for scheduling if it is not locked.
 * In all cases, an event informing the node state's change is propagated to RMMonitoring.
 *
 * @param rmNode node to set free.
 * @return true if the node successfully set as free, false if it was down before.
 */
@VisibleForTesting
BooleanWrapper internalSetFree(final RMNode rmNode) {
    if (logger.isDebugEnabled()) {
        logger.debug("Current node state " + rmNode.getState() + " " + rmNode.getNodeURL());
        logger.debug("Setting node state to free " + rmNode.getNodeURL());
    }
    // If the node is already free no need to go further
    if (rmNode.isFree()) {
        return new BooleanWrapper(true);
    }
    // Get the previous state of the node needed for the event
    final NodeState previousNodeState = rmNode.getState();
    Client client = rmNode.getOwner();
    if (client == null) {
        // node has been just configured, so the user initiated this action is the node provider
        client = rmNode.getProvider();
    }
    // resetting owner here
    rmNode.setFree();
    // an eligible node is a node that is free and not locked
    if (!rmNode.isLocked()) {
        this.eligibleNodes.add(rmNode);
    }
    persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
    this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, client.getName()));
    return new BooleanWrapper(true);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) NodeState(org.ow2.proactive.resourcemanager.common.NodeState) Client(org.ow2.proactive.resourcemanager.authentication.Client) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 5 with RMMonitoring

use of org.ow2.proactive.resourcemanager.frontend.RMMonitoring in project scheduling by ow2-proactive.

the class RMCore method setBusyNode.

/**
 * Set a node state to busy. Set the node to busy, and move the node to the
 * internal busy nodes list. An event informing the node state's change is
 * thrown to RMMonitoring.
 *
 * @param owner
 * @param nodeUrl node to set
 */
public void setBusyNode(final String nodeUrl, Client owner) throws NotConnectedException {
    final RMNode rmNode = this.allNodes.get(nodeUrl);
    if (rmNode == null) {
        logger.error("Unknown node " + nodeUrl);
        return;
    }
    if (!clients.containsKey(owner.getId())) {
        logger.warn(nodeUrl + " cannot set busy as the client disconnected " + owner);
        throw new NotConnectedException("Client " + owner + " is not connected to the resource manager");
    }
    // If the node is already busy no need to go further
    if (rmNode.isBusy()) {
        return;
    }
    // Get the previous state of the node needed for the event
    final NodeState previousNodeState = rmNode.getState();
    rmNode.setBusy(owner);
    this.eligibleNodes.remove(rmNode);
    persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
    // create the event
    this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, owner.getName()));
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) NodeState(org.ow2.proactive.resourcemanager.common.NodeState) NotConnectedException(org.ow2.proactive.resourcemanager.exception.NotConnectedException)

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