Search in sources :

Example 6 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class RMStatistics method nodeEvent.

/**
 * Handle incoming node events of the Resource Manager
 * @param event incoming event
 */
public void nodeEvent(final RMNodeEvent event) {
    // Update cumulative times based on activity and inactivity during the last time interval
    final long currentTimeStamp = System.nanoTime();
    final long timeInterval = currentTimeStamp - this.previousTimeStamp;
    this.cumulativeActivityTime += this.busyNodesCount * timeInterval;
    this.cumulativeInactivityTime += this.freeNodesCount * timeInterval;
    // Update the previous time stamp to the current
    this.previousTimeStamp = currentTimeStamp;
    // Depending on the event type update nodes count
    switch(event.getEventType()) {
        case NODE_ADDED:
            // Increment the available nodes count
            this.availableNodesCount++;
            // We define the state of the added node
            final NodeState addNodeState = event.getNodeState();
            switch(addNodeState) {
                case FREE:
                    this.incrementFreeNodesCount();
                    break;
                case CONFIGURING:
                    this.incrementConfiguringNodesCount();
                    break;
                case DEPLOYING:
                    this.incrementDeployingNodesCount();
                    break;
                case LOST:
                    this.incrementLostNodesCount();
                    break;
                case BUSY:
                    this.incrementBusyNodesCount();
                    break;
                case DOWN:
                    this.incrementDownNodesCount();
                    break;
                case TO_BE_REMOVED:
                    this.incrementToBeRemovedNodesCount();
                    break;
                default:
            }
            break;
        case NODE_REMOVED:
            // Get the state of the node before it was removed
            final NodeState nodeState = event.getNodeState();
            switch(nodeState) {
                case FREE:
                    this.decrementFreeNodesCount();
                    break;
                case BUSY:
                    this.decrementBusyNodesCount();
                    break;
                case TO_BE_REMOVED:
                    this.decrementToBeRemovedNodesCount();
                    break;
                case DOWN:
                    this.decrementDownNodesCount();
                    break;
                case CONFIGURING:
                    this.decrementConfiguringNodesCount();
                    break;
                case LOST:
                    this.decrementLostNodesCount();
                    break;
                case DEPLOYING:
                    this.decrementDeployingNodesCount();
                    break;
                default:
            }
            this.decrementAvailableNodesCount();
            break;
        case NODE_STATE_CHANGED:
            // Depending on the previous state decrement counters
            final NodeState previousNodeState = event.getPreviousNodeState();
            if (previousNodeState != null) {
                switch(previousNodeState) {
                    case FREE:
                        this.decrementFreeNodesCount();
                        break;
                    case BUSY:
                        this.decrementBusyNodesCount();
                        break;
                    case TO_BE_REMOVED:
                        this.decrementToBeRemovedNodesCount();
                        break;
                    case DOWN:
                        this.decrementDownNodesCount();
                        break;
                    case CONFIGURING:
                        this.decrementConfiguringNodesCount();
                        break;
                    case LOST:
                        this.decrementLostNodesCount();
                        break;
                    case DEPLOYING:
                        this.decrementDeployingNodesCount();
                        break;
                    default:
                }
            }
            // can't be null
            final NodeState currentNodeState = event.getNodeState();
            // Depending on the current state increment counters
            switch(currentNodeState) {
                case FREE:
                    this.incrementFreeNodesCount();
                    break;
                case BUSY:
                    this.incrementBusyNodesCount();
                    break;
                case TO_BE_REMOVED:
                    this.incrementToBeRemovedNodesCount();
                    break;
                case DOWN:
                    this.incrementDownNodesCount();
                    break;
                case CONFIGURING:
                    this.incrementConfiguringNodesCount();
                    break;
                case LOST:
                    this.incrementLostNodesCount();
                    break;
                case DEPLOYING:
                    this.incrementDeployingNodesCount();
                    break;
                default:
            }
        default:
    }
}
Also used : NodeState(org.ow2.proactive.resourcemanager.common.NodeState)

Example 7 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class TestExecRemote method action.

@Test
public void action() throws Exception {
    final String miscDir = System.getProperty("pa.rm.home") + File.separator + "samples" + File.separator + "scripts" + File.separator + "misc" + File.separator;
    boolean isLinux = OperatingSystem.getOperatingSystem().equals(OperatingSystem.unix);
    final String valueToEcho = "111";
    String nsName = "TestExecRemote";
    rmHelper.createNodeSource(nsName);
    RMInitialState state = ((RMMonitorEventReceiver) rmHelper.getResourceManager()).getInitialState();
    String hostname = state.getNodeEvents().get(0).getHostName();
    HashSet<String> nodesUrls = new HashSet<>();
    for (RMNodeEvent ne : state.getNodeEvents()) {
        nodesUrls.add(ne.getNodeUrl());
    }
    simpleScript(nodesUrls);
    selectionScript(nodesUrls);
    processBuilderScript(miscDir, isLinux, valueToEcho, nodesUrls);
    processBuilderWithDSScript(miscDir, isLinux, valueToEcho, nodesUrls);
    scriptOnNodeSource(nsName, nodesUrls);
    scriptOnHost(hostname);
}
Also used : RMInitialState(org.ow2.proactive.resourcemanager.common.event.RMInitialState) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) RMMonitorEventReceiver(functionaltests.monitor.RMMonitorEventReceiver) HashSet(java.util.HashSet) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 8 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class RMMonitorsHandler method waitForNodeEvent.

public RMNodeEvent waitForNodeEvent(RMEventType eventType, String nodeUrl, long timeout) throws ProActiveTimeoutException {
    NodeEventMonitor monitor = new NodeEventMonitor(eventType, nodeUrl);
    synchronized (this) {
        if (this.nodesEvent.contains(monitor)) {
            RMNodeEvent event = nodesEvent.get(nodesEvent.indexOf(monitor)).getNodeEvent();
            nodesEvent.remove(monitor);
            return event;
        }
        monitor = (NodeEventMonitor) getMonitor(monitor);
    }
    waitWithMonitor(monitor, timeout);
    return monitor.getNodeEvent();
}
Also used : RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 9 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class TestLocalInfrastructureRestartDownNodesPolicy method testRestartDownNodesPolicyWithRemoveNode.

/**
 * This test ensures that when a node has been manually removed it is not redeployed by the policy
 */
@Test
public void testRestartDownNodesPolicyWithRemoveNode() throws Exception {
    nodeSourceName = "Node_source_2";
    RMTHelper.log("Test 2 - restart down nodes policy with a node removed");
    createNodeSourceWithNodes(nodeSourceName, new Object[] { "ALL", "ALL", "10000" });
    RMState stateTest1 = resourceManager.getState();
    assertEquals(defaultDescriptorNodesNb, stateTest1.getTotalNodesNumber());
    assertEquals(defaultDescriptorNodesNb, stateTest1.getFreeNodesNumber());
    NodeSet ns = resourceManager.getNodes(new Criteria(defaultDescriptorNodesNb));
    for (Node n : ns) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    }
    // remove the first node
    Node nodeToRemove = ns.remove(0);
    resourceManager.removeNode(nodeToRemove.getNodeInformation().getURL(), true);
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, nodeToRemove.getNodeInformation().getURL());
    RMTHelper.log("Node removed.");
    stateTest1 = resourceManager.getState();
    assertEquals(defaultDescriptorNodesNb - 1, stateTest1.getTotalNodesNumber());
    String nodeUrl = ns.get(0).getNodeInformation().getURL();
    // Nodes will be redeployed only if we kill the whole runtime
    rmHelper.killRuntime(nodeUrl);
    // one node is down - the policy should detect it and redeploy
    for (int i = 0; i < defaultDescriptorNodesNb - 1; i++) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, ns.get(i).getNodeInformation().getURL());
    }
    RMNodeEvent ev = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodeUrl);
    assertEquals(NodeState.DOWN, ev.getNodeState());
    // one node is down - the policy should detect it and redeploy
    for (int i = 0; i < defaultDescriptorNodesNb - 1; i++) {
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    }
    // now one node less should be deployed
    assertEquals(defaultDescriptorNodesNb - 1, stateTest1.getTotalNodesNumber());
    assertEquals(defaultDescriptorNodesNb - 1, stateTest1.getTotalAliveNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Node(org.objectweb.proactive.core.node.Node) Criteria(org.ow2.proactive.utils.Criteria) RMState(org.ow2.proactive.resourcemanager.common.RMState) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 10 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class TestSSHInfrastructureV2RestartDownNodesPolicy method testSSHInfrastructureV2WithRestartDownNodes.

@Test
public void testSSHInfrastructureV2WithRestartDownNodes() throws Exception {
    nsname = "testSSHInfraRestart";
    resourceManager = this.rmHelper.getResourceManager();
    RMTHelper.log("Test - Create SSH infrastructure with RestartDownNodes policy on ssh://localhost on port " + TestSSHInfrastructureV2.port);
    resourceManager.createNodeSource(nsname, SSHInfrastructureV2.class.getName(), TestSSHInfrastructureV2.infraParams, RestartDownNodesPolicy.class.getName(), TestSSHInfrastructureV2.policyParameters, NODES_NOT_RECOVERABLE);
    RMMonitorsHandler monitorsHandler = this.rmHelper.getMonitorsHandler();
    this.rmHelper.waitForNodeSourceCreation(nsname, NB_NODES, monitorsHandler);
    RMState s = resourceManager.getState();
    assertEquals(NB_NODES, s.getTotalNodesNumber());
    assertEquals(NB_NODES, s.getFreeNodesNumber());
    NodeSet nodeset = resourceManager.getNodes(new Criteria(NB_NODES));
    if (nodeset.size() != NB_NODES) {
        RMTHelper.log("Illegal state : the infrastructure could not deploy nodes or they died immediately. Ending test");
        throw new RuntimeException("Illegal state : the infrastructure could not deploy nodes or they died immediately. Ending test");
    }
    for (Node n : nodeset) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL(), 60000, monitorsHandler);
    }
    String nodeUrl = nodeset.get(0).getNodeInformation().getURL();
    RMTHelper.log("Killing nodes");
    // Nodes will be redeployed only if we kill the whole runtime
    rmHelper.killRuntime(nodeUrl);
    RMTHelper.log("Wait for down nodes detection by the rm");
    for (Node n : nodeset) {
        RMNodeEvent ev = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL(), 120000, monitorsHandler);
        assertEquals(NodeState.DOWN, ev.getNodeState());
    }
    for (Node n : nodeset) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n.getNodeInformation().getURL(), 120000, monitorsHandler);
    }
    RMTHelper.log("Dumping events not consumed yet");
    monitorsHandler.dumpEvents();
    RMTHelper.log("Wait for nodes restart by the policy");
    rmHelper.waitForAnyMultipleNodeEvent(RMEventType.NODE_ADDED, NB_NODES, monitorsHandler);
    for (int i = 0; i < NB_NODES; i++) {
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED, monitorsHandler);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED, monitorsHandler);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED, monitorsHandler);
    }
    RMTHelper.log("Final checks on the scheduler state");
    nodeset = resourceManager.getNodes(new Criteria(NB_NODES));
    for (Node n : nodeset) {
        System.out.println("NODE::" + n.getNodeInformation().getURL());
    }
    s = resourceManager.getState();
    assertEquals(NB_NODES, s.getTotalNodesNumber());
    // check amount of all nodes that are not down
    assertEquals(NB_NODES, s.getTotalAliveNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) RestartDownNodesPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.RestartDownNodesPolicy) Node(org.objectweb.proactive.core.node.Node) SSHInfrastructureV2(org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructureV2) Criteria(org.ow2.proactive.utils.Criteria) RMState(org.ow2.proactive.resourcemanager.common.RMState) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) RMMonitorsHandler(functionaltests.monitor.RMMonitorsHandler) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Aggregations

RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)27 Test (org.junit.Test)14 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)13 NodeSet (org.ow2.proactive.utils.NodeSet)13 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)10 File (java.io.File)8 TestNode (functionaltests.utils.TestNode)7 Node (org.objectweb.proactive.core.node.Node)7 HashMap (java.util.HashMap)6 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)6 SelectionScript (org.ow2.proactive.scripting.SelectionScript)6 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)5 NodeState (org.ow2.proactive.resourcemanager.common.NodeState)4 RMState (org.ow2.proactive.resourcemanager.common.RMState)4 Criteria (org.ow2.proactive.utils.Criteria)4 ArrayList (java.util.ArrayList)3 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)3 DefaultInfrastructureManager (org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager)3 URI (java.net.URI)2 HashSet (java.util.HashSet)2