use of org.ow2.proactive.utils.Criteria in project scheduling by ow2-proactive.
the class SelectionManagerTest method testSelectNodesWithNoNodes.
@Test
public void testSelectNodesWithNoNodes() {
RMCore rmCore = newMockedRMCore(0);
SelectionManager selectionManager = createSelectionManager(rmCore);
Criteria crit = new Criteria(1);
crit.setTopology(TopologyDescriptor.ARBITRARY);
crit.setScripts(null);
crit.setBlackList(null);
crit.setBestEffort(false);
NodeSet nodeSet = selectionManager.selectNodes(crit, null);
assertEquals(0, nodeSet.size());
}
use of org.ow2.proactive.utils.Criteria in project scheduling by ow2-proactive.
the class SelectionManagerTest method testRunScriptsWillNotBeCalled.
@Test
public void testRunScriptsWillNotBeCalled() {
RMCore rmCore = newMockedRMCore(2);
SelectionManager selectionManager = createSelectionManager(rmCore);
Criteria crit = new Criteria(2);
crit.setTopology(TopologyDescriptor.SINGLE_HOST);
SelectionScript selectWhatever = new SelectionScript();
crit.setScripts(Lists.newArrayList(selectWhatever));
crit.setBlackList(null);
crit.setBestEffort(false);
Client mockedClient = mock(Client.class);
selectionManager.selectNodes(crit, mockedClient);
verify(rmCore, never()).setBusyNode(anyString(), any(Client.class));
}
use of org.ow2.proactive.utils.Criteria in project scheduling by ow2-proactive.
the class ProbabilisticSelectionManagerTest method testSelectNodesWithNoNodes.
@Test
public void testSelectNodesWithNoNodes() {
RMCore rmCore = SelectionManagerTest.newMockedRMCore();
SelectionManager selectionManager = new ProbablisticSelectionManager(rmCore);
Criteria crit = new Criteria(1);
crit.setTopology(TopologyDescriptor.ARBITRARY);
crit.setScripts(null);
crit.setBlackList(null);
crit.setBestEffort(false);
NodeSet nodeSet = selectionManager.selectNodes(crit, null);
assertEquals(0, nodeSet.size());
}
use of org.ow2.proactive.utils.Criteria in project scheduling by ow2-proactive.
the class TopologyNodesFilter method filterBySingleHost.
private List<RMNode> filterBySingleHost(Criteria criteria, List<RMNode> arrangedNodes) {
List<RMNode> arrangedFilteredNodes = new LinkedList<>();
Map<String, List<RMNode>> groupedNodeByHost = new LinkedHashMap<>();
for (RMNode node : arrangedNodes) {
if (!groupedNodeByHost.containsKey(node.getHostName())) {
groupedNodeByHost.put(node.getHostName(), new LinkedList<RMNode>());
}
groupedNodeByHost.get(node.getHostName()).add(node);
}
for (String host : groupedNodeByHost.keySet()) {
if (groupedNodeByHost.get(host).size() >= criteria.getSize()) {
arrangedFilteredNodes.addAll(groupedNodeByHost.get(host));
}
}
return arrangedFilteredNodes;
}
use of org.ow2.proactive.utils.Criteria in project scheduling by ow2-proactive.
the class AddGetRemoveTest method action.
@Test
public void action() throws Exception {
final ResourceManager rm = rmHelper.getResourceManager();
// The username and thr password must be the same a used to connect to the RM
final String adminLogin = TestUsers.TEST.username;
final String adminPassword = TestUsers.TEST.password;
// All accounting values are checked through JMX
final RMAuthentication auth = rmHelper.getRMAuth();
final PublicKey pubKey = auth.getPublicKey();
final Credentials adminCreds = Credentials.createCredentials(new CredData(adminLogin, adminPassword), pubKey);
final JMXServiceURL jmxRmiServiceURL = new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RMI));
final HashMap<String, Object> env = new HashMap<>(1);
env.put(JMXConnector.CREDENTIALS, new Object[] { adminLogin, adminCreds });
// Connect to the JMX RMI Connector Server
final ObjectName myAccountMBeanName = new ObjectName(RMJMXBeans.MYACCOUNT_MBEAN_NAME);
final ObjectName managementMBeanName = new ObjectName(RMJMXBeans.MANAGEMENT_MBEAN_NAME);
final JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxRmiServiceURL, env);
final MBeanServerConnection conn = jmxConnector.getMBeanServerConnection();
// ADD, GET, RELEASE
// 1) ADD
testNode = rmHelper.createNode("test");
Node node = testNode.getNode();
final String nodeURL = node.getNodeInformation().getURL();
rm.addNode(nodeURL).getBooleanValue();
// we eat the configuring to free
rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, nodeURL);
rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodeURL);
// 2) GET
final long beforeGetTime = System.currentTimeMillis();
long originalUsedNodeTime = getUsedNodeTime(myAccountMBeanName, managementMBeanName, conn);
NodeSet nodes = rm.getNodes(new Criteria(1));
rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodeURL);
// Sleep a certain amount of time that will be the minimum amount of the GET->RELEASE duration
Thread.sleep(GR_DURATION);
rm.releaseNodes(nodes);
rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodeURL);
// Check account values validity
long usedNodeTime = getUsedNodeTime(myAccountMBeanName, managementMBeanName, conn) - originalUsedNodeTime;
// 3) REMOVE
rm.removeNode(nodeURL, true).getBooleanValue();
final long getRemoveMaxDuration = System.currentTimeMillis() - beforeGetTime;
assertThat("Invalid value of the usedNodeTime attribute", usedNodeTime, greaterThan(GR_DURATION));
assertThat("Invalid value of the usedNodeTime attribute", usedNodeTime, lessThan(getRemoveMaxDuration));
}
Aggregations