Search in sources :

Example 1 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class topologyConcurrencyTest method action.

@Test
public void action() throws Exception {
    BasicConfigurator.resetConfiguration();
    BasicConfigurator.configure();
    Logger.getLogger(TopologyManager.class).setLevel(Level.DEBUG);
    PAResourceManagerProperties.RM_TOPOLOGY_PINGER.updateProperty(HostsPinger.class.getName());
    PAResourceManagerProperties.RM_TOPOLOGY_ENABLED.updateProperty("true");
    PAResourceManagerProperties.RM_TOPOLOGY_DISTANCE_ENABLED.updateProperty("false");
    final ProActiveRuntimeImpl runtime = mock(ProActiveRuntimeImpl.class);
    when(runtime.getVMInformation()).thenReturn(new DummyVMInfo());
    final TopologyManager manager = new TopologyManager();
    List<Callable<Boolean>> calls = new ArrayList<>(total);
    // first set of tasks, add nodes and remove them
    for (int i = 0; i < total; i++) {
        final int j = i;
        calls.add(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                try {
                    int index = j - (j % collisionSize);
                    Node node = new NodeImpl(runtime, baseUrl + index);
                    if ((j % (collisionSize / 2)) == 0) {
                        manager.addNode(node);
                    } else {
                        // more remove than add, to try to reproduce empty list problems
                        manager.removeNode(node);
                    }
                    // launch some selections on the node just added or removed to trigger ConcurrentModficationExceptions if any
                    NodeSet set = manager.getHandler(TopologyDescriptor.SINGLE_HOST).select(1, Collections.singletonList(node));
                    System.out.println(set);
                } catch (Exception e) {
                    e.printStackTrace();
                    return false;
                }
                return true;
            }
        });
    }
    List<Future<Boolean>> futures = s.invokeAll(calls);
    for (Future<Boolean> fut : futures) {
        Assert.assertTrue(fut.get());
    }
    calls = new ArrayList<>(nbThreads * nodeFactor);
    // second set of task remove all nodes created
    for (int i = 0; i < total; i += collisionSize) {
        final int j = i;
        calls.add(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                try {
                    int index = j;
                    Node node = new NodeImpl(runtime, baseUrl + index);
                    manager.removeNode(node);
                    NodeSet set = manager.getHandler(TopologyDescriptor.SINGLE_HOST).select(1, Collections.singletonList(node));
                    System.out.println(set);
                } catch (Exception e) {
                    e.printStackTrace();
                    return false;
                }
                return true;
            }
        });
    }
    futures = s.invokeAll(calls);
    for (Future<Boolean> fut : futures) {
        Assert.assertTrue(fut.get());
    }
    System.out.println(manager.getTopology().getHosts());
    // finally verify that the nodes on host structure is empty (null)
    Assert.assertNull(manager.getNodesOnHost(DummyVMInfo.address));
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) NodeImpl(org.objectweb.proactive.core.node.NodeImpl) Node(org.objectweb.proactive.core.node.Node) ArrayList(java.util.ArrayList) Callable(java.util.concurrent.Callable) TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) HostsPinger(org.ow2.proactive.resourcemanager.frontend.topology.pinging.HostsPinger) Future(java.util.concurrent.Future) ProActiveRuntimeImpl(org.objectweb.proactive.core.runtime.ProActiveRuntimeImpl) Test(org.junit.Test)

Example 2 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class SelectionManagerTest method testSelectNodesWithNoNodes.

@Test
public void testSelectNodesWithNoNodes() {
    RMCore rmCore = newMockedRMCore(0);
    SelectionManager selectionManager = createSelectionManager(rmCore);
    Criteria crit = new Criteria(1);
    crit.setTopology(TopologyDescriptor.ARBITRARY);
    crit.setScripts(null);
    crit.setBlackList(null);
    crit.setBestEffort(false);
    NodeSet nodeSet = selectionManager.selectNodes(crit, null);
    assertEquals(0, nodeSet.size());
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria) Test(org.junit.Test)

Example 3 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class ProbabilisticSelectionManagerTest method testSelectNodesWithNoNodes.

@Test
public void testSelectNodesWithNoNodes() {
    RMCore rmCore = SelectionManagerTest.newMockedRMCore();
    SelectionManager selectionManager = new ProbablisticSelectionManager(rmCore);
    Criteria crit = new Criteria(1);
    crit.setTopology(TopologyDescriptor.ARBITRARY);
    crit.setScripts(null);
    crit.setBlackList(null);
    crit.setBestEffort(false);
    NodeSet nodeSet = selectionManager.selectNodes(crit, null);
    assertEquals(0, nodeSet.size());
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) SelectionManager(org.ow2.proactive.resourcemanager.selection.SelectionManager) Criteria(org.ow2.proactive.utils.Criteria) SelectionManagerTest(org.ow2.proactive.resourcemanager.selection.SelectionManagerTest) Test(org.junit.Test)

Example 4 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class TopologyManager method getNodeSetWithExtraNodes.

private NodeSet getNodeSetWithExtraNodes(Set<Node> nodes, int numberOfNodesToExtract) {
    Set<Node> main = subListLHS(nodes, 0, numberOfNodesToExtract);
    Set<Node> extra = subListLHS(nodes, numberOfNodesToExtract, nodes.size());
    NodeSet result = new NodeSet(main);
    result.setExtraNodes(extra);
    return result;
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Node(org.objectweb.proactive.core.node.Node)

Example 5 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class TopologyManager method pingNode.

/**
 * Launches the pinging process from new host. It will ping all other hosts
 * according to the pinger logic.
 */
private HashMap<InetAddress, Long> pingNode(Node node, NodeSet nodes) {
    try {
        logger.debug("Launching ping process on node " + node.getNodeInformation().getURL());
        long timeStamp = System.currentTimeMillis();
        Pinger pinger = PAActiveObject.newActive(pingerClass, null, node);
        HashMap<InetAddress, Long> result = pinger.ping(nodes);
        PAFuture.waitFor(result);
        logger.debug(result.size() + " hosts were pinged from " + node.getNodeInformation().getURL() + " in " + (System.currentTimeMillis() - timeStamp) + " ms");
        if (logger.isDebugEnabled()) {
            logger.debug("Distances are:");
            for (InetAddress host : result.keySet()) {
                logger.debug(result.get(host) + " to " + host);
            }
        }
        try {
            PAActiveObject.terminateActiveObject(pinger, true);
        } catch (RuntimeException e) {
            logger.error("Cannot kill the pinger active object", e);
        }
        return result;
    } catch (ActiveObjectCreationException e) {
        logger.warn(e.getMessage(), e);
    } catch (NodeException e) {
        logger.warn(e.getMessage(), e);
    }
    return null;
}
Also used : Pinger(org.ow2.proactive.resourcemanager.frontend.topology.pinging.Pinger) NodeException(org.objectweb.proactive.core.node.NodeException) InetAddress(java.net.InetAddress) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException)

Aggregations

NodeSet (org.ow2.proactive.utils.NodeSet)51 Test (org.junit.Test)28 Criteria (org.ow2.proactive.utils.Criteria)23 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)20 Node (org.objectweb.proactive.core.node.Node)18 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)17 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)12 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)11 SelectionScript (org.ow2.proactive.scripting.SelectionScript)10 File (java.io.File)9 TestNode (functionaltests.utils.TestNode)8 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)7 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)5 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)5 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)4 RMState (org.ow2.proactive.resourcemanager.common.RMState)4 IOException (java.io.IOException)3 Permission (java.security.Permission)3 HashSet (java.util.HashSet)3