Search in sources :

Example 36 with Node

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

the class TestDataSpaceServiceStarter method testTerminateNamingService.

@Test
public // For SCHEDULING-1902, minimal test
void testTerminateNamingService() throws Exception {
    CentralPAPropertyRepository.PA_CLASSLOADING_USEHTTP.setValue(false);
    originalSchedulerHome = PASchedulerProperties.SCHEDULER_HOME.getValueAsString();
    PASchedulerProperties.SCHEDULER_HOME.updateProperty(tmpFolder.newFolder().getAbsolutePath());
    Node node = ProActiveRuntimeImpl.getProActiveRuntime().createLocalNode(TestDataSpaceServiceStarter.class.getSimpleName(), true, null);
    TestDataSpaceServiceStarter activeObject = PAActiveObject.turnActive(new TestDataSpaceServiceStarter(), node);
    activeObject.doTestTerminateNamingService();
}
Also used : Node(org.objectweb.proactive.core.node.Node) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 37 with Node

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

the class OnErrorPolicyInterpreterTest method createTask.

private InternalTask createTask() {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    InternalTask task = new InternalTask(job) {

        @Override
        public boolean handleResultsArguments() {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public TaskLauncher createLauncher(Node node) throws ActiveObjectCreationException, NodeException {
            // TODO Auto-generated method stub
            return null;
        }
    };
    return task;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Node(org.objectweb.proactive.core.node.Node) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob)

Example 38 with Node

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

the class SchedulerTHelper method checkNodesAreClean.

public void checkNodesAreClean(long timeoutValue) throws Exception {
    Set<String> nodeUrls = getResourceManager().listAliveNodeUrls();
    // We wait until no active object remain on the nodes.
    // If AO remains the test will fail with a timeout.
    boolean remainingAO = true;
    Set<Node> nodesWithRemainingAO = new HashSet<>();
    long wait = 0;
    while (remainingAO && wait < timeoutValue) {
        Thread.sleep(50);
        wait += 50;
        remainingAO = false;
        nodesWithRemainingAO.clear();
        for (String nodeUrl : nodeUrls) {
            Node node = NodeFactory.getNode(nodeUrl);
            boolean aoInThisNode = (node.getNumberOfActiveObjects() > 0);
            if (aoInThisNode) {
                nodesWithRemainingAO.add(node);
            }
            remainingAO = remainingAO || aoInThisNode;
        }
    }
    if (remainingAO) {
        for (Node node : nodesWithRemainingAO) {
            log("Found remaining AOs on node " + node.getNodeInformation().getURL() + " " + Arrays.toString(node.getActiveObjects()));
            log("Full stack:");
            System.out.println(node.getThreadDump());
        }
    }
    assertFalse("No Active Objects should remain", remainingAO);
}
Also used : Node(org.objectweb.proactive.core.node.Node) HashSet(java.util.HashSet)

Example 39 with Node

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

the class LiveJobsTest method testFinishInErrorTask.

@Test(timeout = 60000)
public void testFinishInErrorTask() throws UnknownTaskException, UnknownJobException {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CONTINUE_JOB_EXECUTION, "description");
    JobId id = new JobIdImpl(666L, "test-name");
    job.setId(id);
    List<InternalTask> tasksList = new ArrayList<>();
    InternalTask internalTask = new InternalScriptTask(job);
    internalTask.setName("task-name");
    internalTask.setStatus(TaskStatus.IN_ERROR);
    Node node = Mockito.mock(Node.class);
    Mockito.when(node.getVMInformation()).thenAnswer(new Answer<VMInformation>() {

        @Override
        public VMInformation answer(InvocationOnMock invocation) throws Throwable {
            return Mockito.mock(VMInformation.class);
        }
    });
    Mockito.when(node.getNodeInformation()).thenAnswer(new Answer<NodeInformation>() {

        @Override
        public NodeInformation answer(InvocationOnMock invocation) throws Throwable {
            return Mockito.mock(NodeInformation.class);
        }
    });
    TaskLauncher taskLauncher = Mockito.mock(TaskLauncher.class);
    internalTask.setExecuterInformation(new ExecuterInformation(taskLauncher, node));
    tasksList.add(internalTask);
    job.setTasks(tasksList);
    liveJobs.jobSubmitted(job);
    liveJobs.finishInErrorTask(job.getId(), "task-name");
    assertThat(internalTask.getStatus(), is(TaskStatus.FINISHED));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) NodeInformation(org.objectweb.proactive.core.node.NodeInformation) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) VMInformation(org.objectweb.proactive.core.runtime.VMInformation) TaskLauncher(org.ow2.proactive.scheduler.task.TaskLauncher) Node(org.objectweb.proactive.core.node.Node) ArrayList(java.util.ArrayList) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InvocationOnMock(org.mockito.invocation.InvocationOnMock) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 40 with Node

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

the class HACTest method action.

@Test
public void action() throws Exception {
    // building graph
    Node n1 = new DummyNode("1");
    Node n2 = new DummyNode("2");
    Node n3 = new DummyNode("3");
    distances.put(n1, new HashMap<Node, Long>());
    distances.put(n2, new HashMap<Node, Long>());
    distances.put(n3, new HashMap<Node, Long>());
    distances.get(n1).put(n2, (long) 2);
    distances.get(n1).put(n3, (long) 4);
    distances.get(n2).put(n3, (long) -1);
    HAC hac = new HAC(new LocalTopology(), null, BestProximityDescriptor.AVG, Long.MAX_VALUE);
    HAC hacPivot = new HAC(new LocalTopology(), Collections.singletonList(n1), BestProximityDescriptor.AVG, Long.MAX_VALUE);
    log("Test 1: [no pivot], graph [1 -(2)- 2 , 1 -(4)- 3]");
    List<Node> result = hac.select(20, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 2", result.size() == 2);
    if (!(result.contains(new DummyNode("1")) && result.contains(new DummyNode("2")))) {
        fail("Selection is incorrect");
    }
    log("Test 2: [pivot - node 1], graph [1 -(2)- 2 , 1 -(4)- 3]");
    result = hacPivot.select(3, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 1", result.size() == 1);
    if (!result.contains(new DummyNode("2"))) {
        fail("Selection is incorrect");
    }
    distances.get(n2).put(n3, (long) 10);
    log("Test 3: [no pivot], graph [1 -(2)- 2 , 1 -(4)- 3, 2 -(10)- 3]");
    result = hac.select(3, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 3", result.size() == 3);
    log("Test 4: [pivot - node 1], graph [1 -(2)- 2 , 1 -(4)- 3, 2 -(10)- 3]");
    result = hacPivot.select(3, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 2", result.size() == 2);
    if (!(result.contains(new DummyNode("2")) && result.contains(new DummyNode("3")))) {
        fail("Selection is incorrect");
    }
    Node n4 = new DummyNode("4");
    distances.put(n4, new HashMap<Node, Long>());
    distances.get(n2).put(n4, (long) 1);
    distances.get(n3).put(n4, (long) 3);
    distances.get(n1).put(n4, (long) -1);
    log("Test 5: [no pivot], graph [1 -(2)- 2 , 1 -(4)- 3, 2 -(10)- 3, 2 -(1)- 4, 3 -(3)- 4]");
    result = hac.select(4, new LinkedList<>(distances.keySet()));
    // HAC cannot cluster 3 nodes together so the expected result is 2
    assertTrue("Selection size is not 2", result.size() == 2);
    log("Test 6: [pivot - node 1], graph [1 -(2)- 2 , 1 -(4)- 3, 2 -(10)- 3, 2 -(1)- 4, 3 -(3)- 4]");
    result = hacPivot.select(3, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 2", result.size() == 2);
    if (!(result.contains(new DummyNode("2")) && result.contains(new DummyNode("3")))) {
        fail("Selection is incorrect");
    }
    distances.get(n1).put(n4, (long) 3);
    log("Test 7: [no pivot], graph [1 -(2)- 2 , 1 -(4)- 3, 2 -(10)- 3, 2 -(1)- 4, 3 -(3)- 4, 1 -(3)- 4]]");
    result = hac.select(4, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 4", result.size() == 4);
    log("Test 8 - optimal: [no pivot], graph [1 -(2)- 2 , 1 -(4)- 3, 2 -(10)- 3, 2 -(1)- 4, 3 -(3)- 4, 1 -(3)- 4]]");
    result = hac.select(3, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 3", result.size() == 3);
    if (!(result.contains(new DummyNode("1")) && result.contains(new DummyNode("2")) && result.contains(new DummyNode("4")))) {
        fail("Selection is incorrect");
    }
    log("Test 8: [pivot - node 1], graph [1 -(2)- 2 , 1 -(4)- 3, 2 -(10)- 3, 2 -(1)- 4, 3 -(3)- 4, 1 -(3)- 4]]");
    result = hacPivot.select(2, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 2", result.size() == 2);
    if (!(result.contains(new DummyNode("2")) && result.contains(new DummyNode("4")))) {
        fail("Selection is incorrect");
    }
    distances.get(n1).put(n4, (long) 30);
    log("Test 9 - optimal: [no pivot], graph [1 -(2)- 2 , 1 -(4)- 3, 2 -(10)- 3, 2 -(1)- 4, 3 -(3)- 4, 1 -(30)- 4]");
    result = hac.select(3, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 3", result.size() == 3);
    if (!(result.contains(new DummyNode("2")) && result.contains(new DummyNode("3")) && result.contains(new DummyNode("4")))) {
        assertTrue("Selection is incorrect", false);
    }
    Node n5 = new DummyNode("5");
    distances.put(n5, new HashMap<Node, Long>());
    hacPivot = new HAC(new LocalTopology(), Collections.singletonList(n5), BestProximityDescriptor.AVG, Long.MAX_VALUE);
    distances.get(n5).put(n1, (long) -1);
    distances.get(n5).put(n2, (long) -1);
    distances.get(n5).put(n3, (long) 10);
    distances.get(n5).put(n4, (long) 10);
    log("Test 10: [pivot - node 5], graph [1 -(2)- 2 , 1 -(4)- 3, 2 -(10)- 3, 2 -(1)- 4, 3 -(3)- 4, 1 -(30)- 4, 5 -(10)- 3, 5 -(10)- 4]");
    result = hacPivot.select(4, new LinkedList<>(distances.keySet()));
    assertTrue("Selection size is not 2", result.size() == 2);
    if (!(result.contains(new DummyNode("3")) && result.contains(new DummyNode("4")))) {
        fail("Selection is incorrect");
    }
}
Also used : Node(org.objectweb.proactive.core.node.Node) LinkedList(java.util.LinkedList) Test(org.junit.Test)

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