Search in sources :

Example 1 with Criteria

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());
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria) Test(org.junit.Test)

Example 2 with Criteria

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));
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) SelectionScript(org.ow2.proactive.scripting.SelectionScript) Criteria(org.ow2.proactive.utils.Criteria) Client(org.ow2.proactive.resourcemanager.authentication.Client) Test(org.junit.Test)

Example 3 with Criteria

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());
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) SelectionManager(org.ow2.proactive.resourcemanager.selection.SelectionManager) Criteria(org.ow2.proactive.utils.Criteria) SelectionManagerTest(org.ow2.proactive.resourcemanager.selection.SelectionManagerTest) Test(org.junit.Test)

Example 4 with Criteria

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;
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with Criteria

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));
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) NodeSet(org.ow2.proactive.utils.NodeSet) HashMap(java.util.HashMap) PublicKey(java.security.PublicKey) Node(org.objectweb.proactive.core.node.Node) CredData(org.ow2.proactive.authentication.crypto.CredData) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) Criteria(org.ow2.proactive.utils.Criteria) ObjectName(javax.management.ObjectName) RMAuthentication(org.ow2.proactive.resourcemanager.authentication.RMAuthentication) JMXConnector(javax.management.remote.JMXConnector) Credentials(org.ow2.proactive.authentication.crypto.Credentials) MBeanServerConnection(javax.management.MBeanServerConnection) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Aggregations

Criteria (org.ow2.proactive.utils.Criteria)25 NodeSet (org.ow2.proactive.utils.NodeSet)23 Test (org.junit.Test)16 Node (org.objectweb.proactive.core.node.Node)9 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)7 ArrayList (java.util.ArrayList)7 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)6 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)6 CredData (org.ow2.proactive.authentication.crypto.CredData)5 Credentials (org.ow2.proactive.authentication.crypto.Credentials)5 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)5 Client (org.ow2.proactive.resourcemanager.authentication.Client)4 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)4 LinkedList (java.util.LinkedList)3 RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)3 RMState (org.ow2.proactive.resourcemanager.common.RMState)3 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)3 PublicKey (java.security.PublicKey)2 HashMap (java.util.HashMap)2 List (java.util.List)2