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);
}
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
}
}
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;
}
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;
}
Aggregations