Search in sources :

Example 1 with SelectionManager

use of org.ow2.proactive.resourcemanager.selection.SelectionManager 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 SelectionManager

use of org.ow2.proactive.resourcemanager.selection.SelectionManager 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 SelectionManager

use of org.ow2.proactive.resourcemanager.selection.SelectionManager 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 SelectionManager

use of org.ow2.proactive.resourcemanager.selection.SelectionManager in project scheduling by ow2-proactive.

the class ProbabilisticSelectionManagerTest method testDecreasingProbabilityDynamicScriptWithDynamicityStorage.

@Test
public void testDecreasingProbabilityDynamicScriptWithDynamicityStorage() throws Exception {
    int nbNodes = 10;
    SelectionScript script = new SelectionScript("test", "groovy", true);
    ManagerObjects managerObjects = new ManagerObjects(nbNodes).invoke();
    SelectionManager selectionManager = managerObjects.getSelectionManager();
    ArrayList<RMNode> freeNodes = managerObjects.getFreeNodes();
    for (int i = 0; i < nbNodes; i++) {
        // we decrease the probability for each node, lowest node has the max number of false results
        for (int j = i; j < nbNodes; j++) {
            selectionManager.processScriptResult(script, Collections.EMPTY_MAP, new ScriptResult<>(false), freeNodes.get(i));
        }
    }
    List<RMNode> arrangedNodes = selectionManager.arrangeNodesForScriptExecution(freeNodes, Collections.singletonList(script), Collections.EMPTY_MAP);
    // list is supposed to be empty because of dynamicity != 0
    Assert.assertEquals(0, arrangedNodes.size());
}
Also used : SelectionManager(org.ow2.proactive.resourcemanager.selection.SelectionManager) SelectionScript(org.ow2.proactive.scripting.SelectionScript) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) SelectionManagerTest(org.ow2.proactive.resourcemanager.selection.SelectionManagerTest) Test(org.junit.Test)

Example 5 with SelectionManager

use of org.ow2.proactive.resourcemanager.selection.SelectionManager in project scheduling by ow2-proactive.

the class ProbabilisticSelectionManagerTest method testDecreasingProbabilityDynamicScriptWithoutDynamicityStorage.

@Test
public void testDecreasingProbabilityDynamicScriptWithoutDynamicityStorage() throws Exception {
    int nbNodes = 10;
    PAResourceManagerProperties.RM_SELECT_SCRIPT_NODE_DYNAMICITY.updateProperty("0");
    try {
        SelectionScript script = new SelectionScript("test", "groovy", true);
        ManagerObjects managerObjects = new ManagerObjects(nbNodes).invoke();
        SelectionManager selectionManager = managerObjects.getSelectionManager();
        ArrayList<RMNode> freeNodes = managerObjects.getFreeNodes();
        for (int i = 0; i < nbNodes; i++) {
            // we decrease the probability for each node, lowest node has the max number of false results
            for (int j = i; j < nbNodes; j++) {
                selectionManager.processScriptResult(script, Collections.EMPTY_MAP, new ScriptResult<>(false), freeNodes.get(i));
            }
        }
        List<RMNode> arrangedNodes = selectionManager.arrangeNodesForScriptExecution(freeNodes, Collections.singletonList(script), Collections.EMPTY_MAP);
        // list is supposed to contain all nodes because of dynamicity == 0
        Assert.assertEquals(freeNodes.size(), arrangedNodes.size());
        // nodes are expected to be sorted in reverse order
        for (int i = 0; i < nbNodes; i++) {
            Assert.assertEquals("mocked-node-" + (nbNodes - i), arrangedNodes.get(i).getNodeName());
            Assert.assertFalse(selectionManager.isPassed(script, Collections.EMPTY_MAP, arrangedNodes.get(i)));
        }
    } finally {
        PAResourceManagerProperties.RM_SELECT_SCRIPT_NODE_DYNAMICITY.updateProperty("300000");
    }
}
Also used : SelectionManager(org.ow2.proactive.resourcemanager.selection.SelectionManager) SelectionScript(org.ow2.proactive.scripting.SelectionScript) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) SelectionManagerTest(org.ow2.proactive.resourcemanager.selection.SelectionManagerTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)7 SelectionManager (org.ow2.proactive.resourcemanager.selection.SelectionManager)7 SelectionManagerTest (org.ow2.proactive.resourcemanager.selection.SelectionManagerTest)7 SelectionScript (org.ow2.proactive.scripting.SelectionScript)7 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)6 Criteria (org.ow2.proactive.utils.Criteria)6 NodeSet (org.ow2.proactive.utils.NodeSet)5 Client (org.ow2.proactive.resourcemanager.authentication.Client)4 TopologyManager (org.ow2.proactive.resourcemanager.selection.topology.TopologyManager)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 Subject (javax.security.auth.Subject)1 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1 ProActiveException (org.objectweb.proactive.core.ProActiveException)1 StubObject (org.objectweb.proactive.core.mop.StubObject)1 NodeException (org.objectweb.proactive.core.node.NodeException)1 RMAuthenticationImpl (org.ow2.proactive.resourcemanager.authentication.RMAuthenticationImpl)1 NodesCleaner (org.ow2.proactive.resourcemanager.cleaning.NodesCleaner)1 RMEvent (org.ow2.proactive.resourcemanager.common.event.RMEvent)1