Search in sources :

Example 1 with Node

use of org.objectweb.proactive.core.node.Node 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 Node

use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.

the class NodeSourceTest method testDetectedPingedDownNodeCallingInfrastructureManagerInternalRemoveNodeTrueFlag.

@Test
public void testDetectedPingedDownNodeCallingInfrastructureManagerInternalRemoveNodeTrueFlag() throws RMException, ClassNotFoundException {
    Node node = createNode(PROACTIVE_PROGRAMMING_NODE_URL);
    nodeSource.internalAddNode(node);
    nodeSource.detectedPingedDownNode(node.getNodeInformation().getName(), node.getNodeInformation().getURL());
    verify(infrastructureManager).internalNotifyDownNode(anyString(), anyString(), any(Node.class));
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) Test(org.junit.Test)

Example 3 with Node

use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.

the class RMNodeHelper method createNode.

private static Node createNode(String name, String hostname, String nodeUrl, String proActiveRuntimeUrl) {
    VMInformation vmInformation = Mockito.mock(VMInformation.class);
    when(vmInformation.getHostName()).thenReturn(hostname);
    NodeInformation nodeInformation = Mockito.mock(NodeInformation.class);
    when(nodeInformation.getName()).thenReturn(name);
    when(nodeInformation.getURL()).thenReturn(nodeUrl);
    when(nodeInformation.getVMInformation()).thenReturn(vmInformation);
    ProActiveRuntime proActiveRuntime = Mockito.mock(ProActiveRuntime.class);
    when(proActiveRuntime.getURL()).thenReturn(proActiveRuntimeUrl);
    Node node = Mockito.mock(Node.class);
    when(node.getNodeInformation()).thenReturn(nodeInformation);
    when(node.getProActiveRuntime()).thenReturn(proActiveRuntime);
    return node;
}
Also used : NodeInformation(org.objectweb.proactive.core.node.NodeInformation) VMInformation(org.objectweb.proactive.core.runtime.VMInformation) Node(org.objectweb.proactive.core.node.Node) ProActiveRuntime(org.objectweb.proactive.core.runtime.ProActiveRuntime)

Example 4 with Node

use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.

the class SelectionManagerTest method createMockeNode.

public static RMNode createMockeNode(String nodeUser, String nodeName, String nodeUrl) {
    RMNode rmNode = mock(RMNode.class);
    NodeInformation mockedNodeInformation = mock(NodeInformation.class);
    Node node = mock(Node.class);
    when(mockedNodeInformation.getURL()).thenReturn(nodeUrl);
    when(mockedNodeInformation.getName()).thenReturn(nodeName);
    when(node.getNodeInformation()).thenReturn(mockedNodeInformation);
    when(rmNode.getNodeName()).thenReturn(nodeName);
    when(rmNode.getNodeSource()).thenReturn(new NodeSource());
    when(rmNode.getNode()).thenReturn(node);
    when(rmNode.getNodeURL()).thenReturn(nodeUrl);
    when(rmNode.getUserPermission()).thenReturn(new PrincipalPermission("permissions", singleton(new UserNamePrincipal(nodeUser))));
    return rmNode;
}
Also used : UserNamePrincipal(org.ow2.proactive.authentication.principals.UserNamePrincipal) NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) NodeInformation(org.objectweb.proactive.core.node.NodeInformation) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) PrincipalPermission(org.ow2.proactive.permissions.PrincipalPermission)

Example 5 with Node

use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.

the class HAC method getDistance.

/**
 * Calculate the distance from given node to the cluster.
 * This is used in order to filter out the cluster of bigger than needed size.
 */
private long getDistance(Node from, Cluster<Node> to) {
    long globalDistance = 0;
    for (Node n : to.getElements()) {
        long distance = getDistance(from, n);
        globalDistance = distanceFunction.distance(globalDistance, distance);
    }
    return globalDistance;
}
Also used : Node(org.objectweb.proactive.core.node.Node)

Aggregations

Node (org.objectweb.proactive.core.node.Node)80 Test (org.junit.Test)28 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)21 NodeSet (org.ow2.proactive.utils.NodeSet)19 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)18 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)16 HashMap (java.util.HashMap)15 TestNode (functionaltests.utils.TestNode)11 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)11 NodeException (org.objectweb.proactive.core.node.NodeException)9 DefaultInfrastructureManager (org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager)9 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)9 Criteria (org.ow2.proactive.utils.Criteria)8 IOException (java.io.IOException)7 LinkedList (java.util.LinkedList)7 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)7 RMException (org.ow2.proactive.resourcemanager.exception.RMException)7 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)6 InetAddress (java.net.InetAddress)5 ArrayList (java.util.ArrayList)5