Search in sources :

Example 6 with ProActiveTimeoutException

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

the class TestAdminAddingNodes method testAddNodes.

@Test
public void testAddNodes() throws Exception {
    final String NS_NAME = "TestAdminAddingNodes";
    int pingFrequency = 6000;
    ResourceManager resourceManager = rmHelper.getResourceManager();
    resourceManager.createNodeSource(NS_NAME, DefaultInfrastructureManager.class.getName(), null, StaticPolicy.class.getName(), null, NODES_NOT_RECOVERABLE);
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, NS_NAME);
    resourceManager.setNodeSourcePingFrequency(pingFrequency, NS_NAME);
    log("Test 1 : add a node");
    String node1Name = "node1";
    TestNode testNode1 = RMTHelper.createNode(node1Name);
    testNodes.add(testNode1);
    String node1URL = testNode1.getNodeURL();
    resourceManager.addNode(node1URL, NS_NAME);
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node1URL);
    // wait for the node to be in free state
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getTotalAliveNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 2 : remove an already deployed node");
    // preemptive removal is useless for this case, because node is free
    resourceManager.removeNode(node1URL, false);
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, node1URL);
    assertEquals(0, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getTotalAliveNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    log("Test 3 : add a node, kill this node, node is detected down, and add a node that has the same URL");
    // Test seems to have a race condition at this step
    String node2Name = "node2";
    TestNode testNode2 = RMTHelper.createNode(node2Name);
    testNodes.add(testNode2);
    String node2URL = testNode2.getNodeURL();
    resourceManager.addNode(node2URL, NS_NAME);
    // wait the node added event
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node2URL);
    // wait for the node to be in free state
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    assertEquals(1, resourceManager.getState().getTotalAliveNodesNumber());
    testNode2.kill();
    testNodes.remove(testNode2);
    RMNodeEvent evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node2URL);
    assertEquals(evt.getNodeState(), NodeState.DOWN);
    // wait the node down event
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    assertEquals(0, resourceManager.getState().getTotalAliveNodesNumber());
    // create another node with the same URL, and add it to Resource manager
    testNode2 = RMTHelper.createNode(node2Name, new URI(node2URL).getPort());
    testNodes.add(testNode2);
    node2URL = testNode2.getNodeURL();
    resourceManager.addNode(node2URL, NS_NAME);
    // wait the node added event
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node2URL);
    // wait for the node to be in free state
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    assertEquals(1, resourceManager.getState().getTotalAliveNodesNumber());
    log("Test 4 : add a node, keep this node free, kill this node, and add a node that has the same URL");
    // put a large ping frequency in order to avoid down nodes detection
    resourceManager.setNodeSourcePingFrequency(Integer.MAX_VALUE, NS_NAME);
    // wait the end of last ping sequence
    Thread.sleep(pingFrequency * 2);
    // node2 is free, kill the node
    testNode2.kill();
    testNodes.remove(testNode2);
    // create another node with the same URL, and add it to Resource manager
    testNode2 = RMTHelper.createNode(node2Name, new URI(node2URL).getPort());
    testNodes.add(testNode2);
    node2URL = testNode2.getNodeURL();
    resourceManager.addNode(node2URL, NS_NAME);
    NodeFactory.getNode(node2URL);
    // wait the node added event, node added is configuring
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node2URL);
    // wait for the node to be in free state
    rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node2URL);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 5 : add a node, put this node busy, kill this node, and add a node that has the same URL");
    // put the the node to busy state
    NodeSet nodes = resourceManager.getAtMostNodes(1, null);
    PAFuture.waitFor(nodes);
    // wait the node busy event
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node2URL);
    assertEquals(evt.getNodeState(), NodeState.BUSY);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    // node2 is busy, kill the node
    testNode2.kill();
    testNodes.remove(testNode2);
    // create another node with the same URL, and add it to Resource manager
    testNode2 = RMTHelper.createNode(node2Name, new URI(node2URL).getPort());
    testNodes.add(testNode2);
    node2URL = testNode2.getNodeURL();
    resourceManager.addNode(node2URL, NS_NAME);
    NodeFactory.getNode(node2URL);
    // wait the node added event, node added is configuring
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node2URL);
    // wait for the node to be in free state
    rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node2URL);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 6 : add a node, put this node toRelease, kill this node, and add a node that has the same URL");
    // put the the node to busy state
    nodes = resourceManager.getAtMostNodes(1, null);
    PAFuture.waitFor(nodes);
    // wait the node busy event
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node2URL);
    assertEquals(evt.getNodeState(), NodeState.BUSY);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    // put the node in to Release state
    resourceManager.removeNode(node2URL, false);
    // wait the node to release event
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node2URL);
    assertEquals(evt.getNodeState(), NodeState.TO_BE_REMOVED);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    testNode2.kill();
    testNodes.remove(testNode2);
    // create another node with the same URL, and add it to Resource manager
    testNode2 = RMTHelper.createNode(node2Name, new URI(node2URL).getPort());
    testNodes.add(testNode2);
    node2URL = testNode2.getNodeURL();
    resourceManager.addNode(node2URL, NS_NAME);
    NodeFactory.getNode(node2URL);
    // wait the node added event, node added is configuring
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node2URL);
    // wait for the node to be in free state
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node2URL);
    assertEquals(evt.getNodeState(), NodeState.FREE);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 7");
    // add the same node twice and check that RM will not kill the node. If it does
    // second attempt will fail
    BooleanWrapper result = resourceManager.addNode(node2URL, NS_NAME);
    assertFalse(result.getBooleanValue());
    try {
        rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node2URL, 8000);
        fail("Should timeout");
    } catch (ProActiveTimeoutException expected) {
    // expected
    }
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) DefaultInfrastructureManager(org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager) StaticPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy) TestNode(functionaltests.utils.TestNode) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) URI(java.net.URI) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 7 with ProActiveTimeoutException

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

the class TestConcurrentUsers method testConcurrency.

@Test
public void testConcurrency() throws Exception {
    ResourceManager resourceManager = rmHelper.getResourceManager();
    String nsName = "TestConcurrentUsers";
    String node1Name = "node1";
    testNode = rmHelper.createNode(node1Name);
    String node1URL = testNode.getNode().getNodeInformation().getURL();
    resourceManager.createNodeSource(nsName, DefaultInfrastructureManager.class.getName(), null, StaticPolicy.class.getName(), null, NODES_NOT_RECOVERABLE);
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, nsName);
    resourceManager.addNode(node1URL, nsName);
    // waiting for node adding event
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node1URL);
    // waiting for the node to be free
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    assertTrue(resourceManager.getState().getTotalNodesNumber() == 1);
    assertTrue(resourceManager.getState().getFreeNodesNumber() == 1);
    log("Test 1 - releasing of the foreign node");
    // acquiring a node
    final NodeSet ns = resourceManager.getAtMostNodes(1, null);
    // waiting for node busy event
    RMNodeEvent evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node1URL);
    assertEquals(evt.getNodeState(), NodeState.BUSY);
    assertEquals(ns.size(), 1);
    assertTrue(resourceManager.getState().getTotalNodesNumber() == 1);
    assertTrue(resourceManager.getState().getFreeNodesNumber() == 0);
    Thread t = new Thread() {

        @Override
        public void run() {
            try {
                Credentials cred = Credentials.createCredentials(new CredData(CredData.parseLogin("user"), CredData.parseDomain("user"), "pwd"), TestConcurrentUsers.this.rmHelper.getRMAuth().getPublicKey());
                ResourceManager rm2 = TestConcurrentUsers.this.rmHelper.getRMAuth().login(cred);
                rm2.releaseNode(ns.get(0)).getBooleanValue();
                Assert.assertTrue("Should not be able to release foreign node", false);
            } catch (Exception e) {
                log(e.getMessage());
            }
        }
    };
    t.start();
    t.join();
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    resourceManager.releaseNodes(ns);
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node1URL);
    assertEquals(evt.getNodeState(), NodeState.FREE);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 2 - releasing node twice");
    resourceManager.releaseNodes(ns);
    // to make sure everything has been processed
    Thread.sleep(1000);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 3 - client crash detection");
    JVMProcessImpl nodeProcess = new JVMProcessImpl(new org.objectweb.proactive.core.process.AbstractExternalProcess.StandardOutputMessageLogger());
    nodeProcess.setJvmOptions(Collections.singletonList(PAResourceManagerProperties.RM_HOME.getCmdLine() + PAResourceManagerProperties.RM_HOME.getValueAsString()));
    nodeProcess.setClassname(GetAllNodes.class.getName());
    nodeProcess.startProcess();
    // node busy event
    for (int i = 0; i < 1; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(evt.getNodeState(), NodeState.BUSY);
    }
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    // client does not exist anymore
    log("Client does not exist anymore. Waiting for client crash detection.");
    // waiting for node free event
    for (int i = 0; i < 1; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.FREE, evt.getNodeState());
    }
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 4 - disconnecting");
    NodeSet ns2 = resourceManager.getAtMostNodes(1, null);
    RMNodeEvent event = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED, 10000);
    Assert.assertTrue(event.getNodeState() == NodeState.BUSY);
    PAFuture.waitFor(ns2);
    log("Number of found nodes " + ns2.size());
    assertEquals(1, ns2.size());
    t = new Thread() {

        public void run() {
            try {
                RMAuthentication auth = rmHelper.getRMAuth();
                Credentials cred = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), auth.getPublicKey());
                ResourceManager rm = auth.login(cred);
                rm.disconnect().getBooleanValue();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
    t.start();
    t.join();
    try {
        event = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED, 10000);
        fail("Unexpected event: " + event);
    } catch (ProActiveTimeoutException e) {
    }
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) DefaultInfrastructureManager(org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager) StaticPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy) CredData(org.ow2.proactive.authentication.crypto.CredData) JVMProcessImpl(org.objectweb.proactive.core.process.JVMProcessImpl) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) RMAuthentication(org.ow2.proactive.resourcemanager.authentication.RMAuthentication) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 8 with ProActiveTimeoutException

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

the class TestNodesStates method testManyStatesChanges.

@Test
public void testManyStatesChanges() throws Exception {
    ResourceManager resourceManager = rmHelper.getResourceManager();
    int totalNodeNumber = 5;
    rmHelper.createNodeSource("TestNodesStates", totalNodeNumber);
    // ----------------------------------------------------------
    // Book all nodes deployed by descriptor (user action)
    // verify that there are no free nodes left,
    // and give back to RM
    log("Test 1");
    NodeSet nodes = resourceManager.getAtMostNodes(totalNodeNumber, null);
    PAFuture.waitFor(nodes);
    assertEquals(totalNodeNumber, nodes.size());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    for (int i = 0; i < totalNodeNumber; i++) {
        RMNodeEvent evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodes.get(i).getNodeInformation().getURL());
        assertEquals(NodeState.BUSY, evt.getNodeState());
        checkEvent(evt, nodes.get(i));
    }
    // for next test
    Node n = nodes.get(0);
    resourceManager.releaseNodes(nodes);
    for (int i = 0; i < totalNodeNumber; i++) {
        RMNodeEvent evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodes.get(i).getNodeInformation().getURL());
        assertEquals(NodeState.FREE, evt.getNodeState());
        checkEvent(evt, nodes.get(i));
    }
    // ----------------------------------------------------------
    // give back a node already given back (i.e; node already free)
    // this action causes nothing(nor increasing free nodes number, nor generation of any event)
    log("Test 2");
    resourceManager.releaseNode(n);
    boolean timeouted = false;
    try {
        rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL(), 4000);
    } catch (ProActiveTimeoutException e) {
        timeouted = true;
    }
    assertTrue(timeouted);
    assertEquals(totalNodeNumber, resourceManager.getState().getFreeNodesNumber());
    // ----------------------------------------------------------
    // Book all nodes deployed by descriptor
    // Test admin action : Remove a node from the RM (non preemptively),
    // node is busy, so becomes in "toRelease" state
    // user give back to RM the "toRelease" node, node is now removed
    log("Test 3");
    nodes = resourceManager.getAtMostNodes(totalNodeNumber, null);
    PAFuture.waitFor(nodes);
    for (int i = 0; i < totalNodeNumber; i++) {
        RMNodeEvent evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.BUSY, evt.getNodeState());
    }
    n = nodes.remove(0);
    // put node in "To Release" state
    resourceManager.removeNode(n.getNodeInformation().getURL(), false);
    // check that node toRelease event has been thrown
    RMNodeEvent evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    assertEquals(NodeState.TO_BE_REMOVED, evt.getNodeState());
    // node is in "ToRelease" state, so always handled by RM
    assertEquals(totalNodeNumber, resourceManager.getState().getTotalNodesNumber());
    // user give back the node, so node is now removed
    resourceManager.releaseNode(n);
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n.getNodeInformation().getURL());
    // ----------------------------------------------------------
    // nodes are always in busy state
    // kill JVM of a node (simulate a fallen JVM or broken connection, i.e down node)
    // node must detected down by RM
    log("Test 4");
    n = nodes.get(0);
    // for next test
    Node n2 = nodes.get(1);
    try {
        n.getProActiveRuntime().killNode(n.getNodeInformation().getName());
    } catch (Exception e) {
        e.printStackTrace();
    }
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    assertEquals(NodeState.DOWN, evt.getNodeState());
    checkEvent(evt, n);
    resourceManager.releaseNodes(nodes);
    for (int i = 0; i < totalNodeNumber - 2; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.FREE, evt.getNodeState());
    }
    // two nodes killed, but the detected down is in RM down nodes list
    // ( down nodes are in total nodes count)
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 2, resourceManager.getState().getFreeNodesNumber());
    // ----------------------------------------------------------
    // nodes left are in free state
    // kill JVM of a free node
    // node must detected down by RM
    log("Test 5");
    try {
        n2.getProActiveRuntime().killNode(n2.getNodeInformation().getName());
    } catch (Exception e) {
        e.printStackTrace();
    }
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n2.getNodeInformation().getURL());
    assertEquals(NodeState.DOWN, evt.getNodeState());
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 3, resourceManager.getState().getFreeNodesNumber());
    // ----------------------------------------------------------
    // book nodes, put one node in "toRelease" state,
    // then kill its JVM,
    // node must detected down by RM
    log("Test 6");
    nodes = resourceManager.getAtMostNodes(totalNodeNumber - 3, null);
    PAFuture.waitFor(nodes);
    for (int i = 0; i < totalNodeNumber - 3; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.BUSY, evt.getNodeState());
    }
    n = nodes.get(0);
    // for next test
    n2 = nodes.get(1);
    // put node in "To Release" state
    resourceManager.removeNode(n.getNodeInformation().getURL(), false);
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    assertEquals(NodeState.TO_BE_REMOVED, evt.getNodeState());
    log("Test 6 Bis");
    // kill the node
    try {
        n.getProActiveRuntime().killNode(n.getNodeInformation().getName());
    } catch (Exception e) {
        e.printStackTrace();
    }
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    assertEquals(NodeState.DOWN, evt.getNodeState());
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    for (Node node : nodes) {
        log("Taken node: " + node.getNodeInformation().getURL());
    }
    // we have 2 nodes: 11 busy and one still down
    resourceManager.releaseNodes(nodes);
    for (int i = 0; i < 1; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.FREE, evt.getNodeState());
    }
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 4, resourceManager.getState().getFreeNodesNumber());
    // admin removes again the node, ok he already asked this removal when node n was busy
    // choice here is advert admin that node has fallen (not hiding the down node event),
    // rather than automatically remove it
    resourceManager.removeNode(n.getNodeInformation().getURL(), false);
    // check that node removed event has been received
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n.getNodeInformation().getURL());
    assertEquals(totalNodeNumber - 2, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 4, resourceManager.getState().getFreeNodesNumber());
    // ----------------------------------------------------------
    // Remove a free node,
    // 
    log("Test 7");
    resourceManager.removeNode(n2.getNodeInformation().getURL(), false);
    // check that node removed event has been received
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n2.getNodeInformation().getURL());
    assertEquals(totalNodeNumber - 3, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 5, resourceManager.getState().getFreeNodesNumber());
    log("End of test");
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) Node(org.objectweb.proactive.core.node.Node) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 9 with ProActiveTimeoutException

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

the class SchedulerMonitorsHandler method waitWithMonitor.

// ---------------------------------------------------------------//
// private methods
// these methods MUST NOT be called from a synchronized(this) block
// ---------------------------------------------------------------//
private void waitWithMonitor(EventMonitor monitor, long timeout) throws ProActiveTimeoutException {
    TimeoutAccounter counter = TimeoutAccounter.getAccounter(timeout);
    synchronized (monitor) {
        monitor.setTimeouted(false);
        while (!counter.isTimeoutElapsed()) {
            if (monitor.eventOccured())
                return;
            try {
                // System.out.println("I AM WAITING FOR EVENT : " + monitor.getWaitedEvent() + " during " +
                // counter.getRemainingTimeout());
                monitor.wait(counter.getRemainingTimeout());
            } catch (InterruptedException e) {
                // spurious wake-up, nothing to do
                e.printStackTrace();
            }
        }
        monitor.setTimeouted(true);
    }
    throw new ProActiveTimeoutException("timeout elapsed");
}
Also used : ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) TimeoutAccounter(org.objectweb.proactive.utils.TimeoutAccounter)

Example 10 with ProActiveTimeoutException

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

the class TestJobKilled method testJobKilled.

@Test
public void testJobKilled() throws Throwable {
    String task1Name = "task1";
    String task2Name = "task2";
    String task3Name = "task3";
    // cannot use SchedulerTHelper.testJobsubmission because
    // task 3 is never executed so no event can be received
    // regarding this task.
    JobId id = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    // check events reception
    log("Job submitted, id " + id.toString());
    log("Waiting for jobSubmitted");
    schedulerHelper.waitForEventJobSubmitted(id);
    log("Waiting for job running");
    schedulerHelper.waitForEventJobRunning(id);
    log("Waiting for task running : " + task1Name);
    schedulerHelper.waitForEventTaskRunning(id, task1Name);
    log("Waiting for task finished : " + task1Name);
    schedulerHelper.waitForEventTaskFinished(id, task1Name);
    log("Waiting for task running : " + task2Name);
    schedulerHelper.waitForEventTaskRunning(id, task2Name);
    log("Waiting for task finished : " + task2Name);
    schedulerHelper.waitForEventTaskFinished(id, task2Name);
    log("Waiting for job finished");
    schedulerHelper.waitForEventJobFinished(id);
    try {
        schedulerHelper.waitForEventTaskRunning(id, task3Name, 1000);
        fail("Task 3 should not be started");
    } catch (ProActiveTimeoutException expected) {
    // expected
    }
    JobResult res = schedulerHelper.getJobResult(id);
    Map<String, TaskResult> results = res.getAllResults();
    // check that all tasks results are defined
    assertNotNull(results.get("task1").value());
    assertNotNull(results.get("task2").getException());
}
Also used : ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)10 Test (org.junit.Test)6 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)4 NodeSet (org.ow2.proactive.utils.NodeSet)4 TimeoutAccounter (org.objectweb.proactive.utils.TimeoutAccounter)3 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)3 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)3 File (java.io.File)2 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)2 DefaultInfrastructureManager (org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager)2 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)2 JobId (org.ow2.proactive.scheduler.common.job.JobId)2 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 TestNode (functionaltests.utils.TestNode)1 URI (java.net.URI)1 Node (org.objectweb.proactive.core.node.Node)1 JVMProcessImpl (org.objectweb.proactive.core.process.JVMProcessImpl)1 CredData (org.ow2.proactive.authentication.crypto.CredData)1 Credentials (org.ow2.proactive.authentication.crypto.Credentials)1