use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class TestAddRemoveAll method testCreateNodeSource.
@Test
public void testCreateNodeSource() throws Exception {
ResourceManager resourceManager = rmHelper.getResourceManager();
int pingFrequency = 6000;
log("Add/RemoveAll");
resourceManager.createNodeSource(nsName, DefaultInfrastructureManager.class.getName(), null, StaticPolicy.class.getName(), null, NODES_NOT_RECOVERABLE);
rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, nsName);
resourceManager.setNodeSourcePingFrequency(pingFrequency, nsName);
testNode = rmHelper.createNode(nodeName);
Node nodeToAdd = testNode.getNode();
resourceManager.addNode(nodeToAdd.getNodeInformation().getURL(), nsName).getBooleanValue();
// at this time, nodes maybe fully added in the nodesource but not in the core
// the next removal may fail for some nodes that are not known by the core...
resourceManager.removeNodeSource(nsName, true);
rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, nsName);
Thread.sleep(pingFrequency * 2);
if (resourceManager.getState().getTotalNodesNumber() != 0) {
log("The removeAll method in RMCore didn't removed all nodes");
fail();
} else {
log("The removeAll method in RMCore did its job well");
}
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMFunctionalTest method cleanState.
/**
* Remove all node sources and nodes in the RM
*
* @throws Exception
*/
private void cleanState() throws Exception {
if (rmHelper.isRMStarted()) {
// force reconnection
rmHelper.disconnect();
ResourceManager rm = rmHelper.getResourceManager();
int nodeNumber = rm.getState().getTotalNodesNumber();
RMInitialState state = ((RMMonitorEventReceiver) rmHelper.getResourceManager()).getInitialState();
for (RMNodeSourceEvent sourceEvent : state.getNodeSourceEvents()) {
String nodeSource = sourceEvent.getSourceName();
rm.removeNodeSource(nodeSource, true);
rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, nodeSource);
}
for (int i = 0; i < nodeNumber; i++) {
rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED);
}
}
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCoreTest method testLockNodeState.
private void testLockNodeState(NodeState nodeState) {
RMNodeImpl rmNode = spy(RMNodeHelper.basicWithMockedInternals().getLeft());
rmNode.setState(nodeState);
HashMap<String, RMNode> allNodes = new HashMap<>();
allNodes.put(rmNode.getNodeURL(), rmNode);
ArrayList<RMNode> freeNodes = Lists.newArrayList((RMNode) rmNode);
RMCore rmCore = new RMCore(new HashMap<String, NodeSource>(), allNodes, Mockito.mock(Client.class), Mockito.mock(RMMonitoringImpl.class), Mockito.mock(SelectionManager.class), freeNodes, Mockito.mock(RMDBManager.class));
rmCore.signalRMCoreIsInitialized();
BooleanWrapper lockResult = rmCore.lockNodes(ImmutableSet.of(rmNode.getNodeURL()));
assertThat(lockResult.getBooleanValue()).isTrue();
assertThat(rmNode.getState()).isEqualTo(nodeState);
assertThat(rmNode.isLocked()).isTrue();
assertThat(freeNodes).isEmpty();
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMRestTest method testAddNodeOverloading.
// PORTAL-326
@Test
public void testAddNodeOverloading() throws Exception {
RMProxyUserInterface rm = mock(RMProxyUserInterface.class);
String sessionId = SharedSessionStoreTestUtils.createValidSession(rm);
when(rm.addNode(anyString())).thenReturn(new BooleanWrapper(true));
List<NameValuePair> firstCall = Collections.<NameValuePair>singletonList(new BasicNameValuePair("nodeurl", "url"));
callHttpPostMethod("node", sessionId, firstCall);
verify(rm).addNode("url");
reset(rm);
when(rm.addNode(anyString(), anyString())).thenReturn(new BooleanWrapper(true));
List<NameValuePair> secondCall = new ArrayList<>();
secondCall.add(new BasicNameValuePair("nodeurl", "urlwithnsname"));
secondCall.add(new BasicNameValuePair("nodesource", "ns"));
callHttpPostMethod("node", sessionId, secondCall);
verify(rm).addNode("urlwithnsname", "ns");
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCore method removeDeployingNode.
/**
* To handle the deploying node removal
*
* @param url the url of the deploying node to remove
* @return true if successful, false otherwise
*/
private boolean removeDeployingNode(String url) {
String nsName = "";
try {
URI urlObj = new URI(url);
nsName = urlObj.getHost();
} catch (URISyntaxException e) {
logger.warn("No such deploying node: " + url);
return false;
}
if (nsName == null) {
// cannot compute the nsName using URI, try using Pattern
Matcher matcher = Pattern.compile(RMDeployingNode.PROTOCOL_ID + "://([-\\w]+)/.+").matcher(url);
if (matcher.find()) {
try {
nsName = matcher.group(1);
} catch (IndexOutOfBoundsException e) {
logger.debug("Was not able to determine nodesource's name for url " + url);
}
}
}
NodeSource ns = this.deployedNodeSources.get(nsName);
if (ns == null) {
logger.warn("No such nodesource: " + nsName + ", cannot remove the deploying node with url: " + url);
return false;
}
return ns.removeDeployingNode(url);
}
Aggregations