Search in sources :

Example 11 with RMState

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

the class TestLocalInfrastructureStaticPolicy method action.

@Test
public void action() throws Exception {
    String source1 = "Node_source_1";
    ResourceManager resourceManager = rmHelper.getResourceManager();
    log("Test 1 - creation/removal of empty node source");
    log("creation");
    createEmptyNodeSource(source1);
    log("removal");
    resourceManager.removeNodeSource(source1, true);
    log("ask to remove NS");
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, source1);
    log("NS removed");
    String source2 = "Node_source_2";
    log("Test 2 - creation/removal of the node source with nodes");
    createNodeSourceWithNodes(source1);
    RMState s = resourceManager.getState();
    assertEquals(defaultDescriptorNodesNb, s.getTotalNodesNumber());
    assertEquals(defaultDescriptorNodesNb, s.getFreeNodesNumber());
    // releasing some nodes
    NodeSet ns = resourceManager.getAtMostNodes(defaultDescriptorNodesNb, null);
    for (Node n : ns) {
        // eat the freeToBusy event
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        resourceManager.removeNode(n.getNodeInformation().getURL(), true);
        rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n.getNodeInformation().getURL());
    }
    assertEquals(0, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    log("removal");
    resourceManager.removeNodeSource(source1, true);
    log("ask to remove NS");
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, source1);
    log("NS removed");
    log("Test 3 - several node sources");
    createNodeSourceWithNodes(source1);
    createNodeSourceWithNodes(source2);
    assertEquals(2 * defaultDescriptorNodesNb, resourceManager.getState().getTotalNodesNumber());
    assertEquals(2 * defaultDescriptorNodesNb, resourceManager.getState().getFreeNodesNumber());
    resourceManager.removeNodeSource(source1, true);
    // wait the n events of the n nodes removals of the node source
    for (int i = 0; i < defaultDescriptorNodesNb; i++) {
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED);
    }
    // wait for the event of the node source removal
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, source1);
    resourceManager.removeNodeSource(source2, true);
    for (int i = 0; i < defaultDescriptorNodesNb; i++) {
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED);
    }
    // wait for the event of the node source removal
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, source2);
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Node(org.objectweb.proactive.core.node.Node) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMState(org.ow2.proactive.resourcemanager.common.RMState) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 12 with RMState

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

the class SessionSharingTest method sessions_are_shared_scheduler_login.

@Test
public void sessions_are_shared_scheduler_login() throws Exception {
    String sessionId = schedulerRest.login("login", "pw");
    when(rmMock.getState()).thenReturn(new RMState(new RMStateNodeUrls(new HashSet<String>(), new HashSet<String>(), new HashSet<String>()), Long.valueOf(-1)));
    RMState rmState = rmRest.getState(sessionId);
    assertNotNull(rmState);
    when(schedulerMock.freeze()).thenReturn(true);
    boolean frozen = schedulerRest.freezeScheduler(sessionId);
    assertTrue(frozen);
    schedulerRest.disconnect(sessionId);
    try {
        rmRest.getState(sessionId);
        fail();
    } catch (NotConnectedException expected) {
    // expected
    }
    try {
        schedulerRest.freezeScheduler(sessionId);
        fail();
    } catch (NotConnectedRestException expected) {
    // expected
    }
}
Also used : NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) RMState(org.ow2.proactive.resourcemanager.common.RMState) RMStateNodeUrls(org.ow2.proactive.resourcemanager.common.RMStateNodeUrls) Test(org.junit.Test)

Example 13 with RMState

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

the class RMCore method getState.

/**
 * {@inheritDoc}
 */
public RMState getState() {
    RMStateNodeUrls rmStateNodeUrls = new RMStateNodeUrls(nodesListToUrlsSet(eligibleNodes), listAliveNodeUrls(), nodesListToUrlsSet(allNodes.values()));
    RMState state = new RMState(rmStateNodeUrls, maximumNumberOfNodes);
    return state;
}
Also used : RMState(org.ow2.proactive.resourcemanager.common.RMState) RMStateNodeUrls(org.ow2.proactive.resourcemanager.common.RMStateNodeUrls)

Example 14 with RMState

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

the class RunningTaskRecoveryWhenNodesAreReservedInBatchTest method printRmStateAndReturnNotFreeNodeNumber.

private int printRmStateAndReturnNotFreeNodeNumber() throws Exception {
    ResourceManager rm = schedulerHelper.getResourceManager();
    RMState rmState = rm.getState();
    int totalNodesNumber = rmState.getTotalNodesNumber();
    int freeNodesNumber = rmState.getFreeNodesNumber();
    // just to give *an idea* of how many node are free/busy  just before
    // killing the scheduler
    SchedulerTHelper.log("Total node number " + totalNodesNumber);
    SchedulerTHelper.log("Free node number " + freeNodesNumber);
    return totalNodesNumber - freeNodesNumber;
}
Also used : ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMState(org.ow2.proactive.resourcemanager.common.RMState)

Aggregations

RMState (org.ow2.proactive.resourcemanager.common.RMState)14 Test (org.junit.Test)9 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)6 Node (org.objectweb.proactive.core.node.Node)4 NodeSet (org.ow2.proactive.utils.NodeSet)4 RMStateNodeUrls (org.ow2.proactive.resourcemanager.common.RMStateNodeUrls)3 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)3 Criteria (org.ow2.proactive.utils.Criteria)3 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)2 SSHInfrastructureV2 (org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructureV2)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)2 RMMonitorsHandler (functionaltests.monitor.RMMonitorsHandler)1 RestartDownNodesPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.RestartDownNodesPolicy)1 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)1