Search in sources :

Example 6 with SelectionManager

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

the class ProbabilisticSelectionManagerTest method testIncreasingProbabilityStatic.

@Test
public void testIncreasingProbabilityStatic() throws Exception {
    int nbNodes = 10;
    SelectionScript script = new SelectionScript("test", "groovy", false);
    ManagerObjects managerObjects = new ManagerObjects(nbNodes).invoke();
    SelectionManager selectionManager = managerObjects.getSelectionManager();
    ArrayList<RMNode> freeNodes = managerObjects.getFreeNodes();
    for (int i = 0; i < nbNodes; i++) {
        // we increase the probability for each node, but it should not change the result for static scripts
        for (int j = 0; j < i + 1; j++) {
            selectionManager.processScriptResult(script, Collections.EMPTY_MAP, new ScriptResult<>(true), freeNodes.get(i));
        }
    }
    List<RMNode> arrangedNodes = selectionManager.arrangeNodesForScriptExecution(freeNodes, Collections.singletonList(script), Collections.EMPTY_MAP);
    // nodes are expected to be sorted in initial order
    for (int i = 0; i < nbNodes; i++) {
        Assert.assertEquals("mocked-node-" + (i + 1), arrangedNodes.get(i).getNodeName());
        Assert.assertTrue(selectionManager.isPassed(script, Collections.EMPTY_MAP, arrangedNodes.get(i)));
    }
}
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 7 with SelectionManager

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

the class RMCore method initActivity.

/**
 * Initialization part of the RMCore active object.
 * Create RM's active objects and the default static Node Source named
 * {@link RMConstants#DEFAULT_STATIC_SOURCE_NAME}. Finally, it throws the RM
 * started event.
 *
 * @param body the active object's body.
 */
public void initActivity(Body body) {
    if (logger.isDebugEnabled()) {
        logger.debug("RMCore start : initActivity");
    }
    try {
        // setting up the policy
        logger.debug("Setting up the resource manager security policy");
        ClientsPolicy.init();
        StubObject rmCoreStub = PAActiveObject.getStubOnThis();
        PAActiveObject.registerByName(rmCoreStub, RMConstants.NAME_ACTIVE_OBJECT_RMCORE);
        dbManager = RMDBManager.getInstance();
        if (logger.isDebugEnabled()) {
            logger.debug("Creating RMAuthentication active object");
        }
        authentication = (RMAuthenticationImpl) PAActiveObject.newActive(RMAuthenticationImpl.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        if (logger.isDebugEnabled()) {
            logger.debug("Creating RMMonitoring active object");
        }
        // Boot the JMX infrastructure
        this.jmxHelper.boot(authentication);
        monitoring = (RMMonitoringImpl) PAActiveObject.newActive(RMMonitoringImpl.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        if (logger.isDebugEnabled()) {
            logger.debug("Creating SelectionManager active object");
        }
        selectionManager = (SelectionManager) PAActiveObject.newActive(ProbablisticSelectionManager.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        if (logger.isDebugEnabled()) {
            logger.debug("Creating ClientPinger active object");
        }
        clientPinger = (ClientPinger) PAActiveObject.newActive(ClientPinger.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        if (logger.isDebugEnabled()) {
            logger.debug("Creating NodeCleaner active object");
        }
        nodesCleaner = (NodesCleaner) PAActiveObject.newActive(NodesCleaner.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        topologyManager = new TopologyManager();
        nodeConfigurator = (RMNodeConfigurator) PAActiveObject.newActive(RMNodeConfigurator.class.getName(), new Object[] { rmCoreStub }, nodeRM);
        // adding shutdown hook
        final RMCore rmcoreStub = (RMCore) rmCoreStub;
        Runtime.getRuntime().addShutdownHook(new Thread() {

            @Override
            public void run() {
                if (!toShutDown) {
                    rmcoreStub.shutdown(true);
                }
                synchronized (nodeRM) {
                    if (!shutedDown) {
                        try {
                            // wait for rmcore shutdown (5 min at most)
                            nodeRM.wait(5 * 60 * 60 * 1000);
                        } catch (InterruptedException e) {
                            logger.warn("shutdown hook interrupted", e);
                        }
                    }
                }
            }
        });
        // Creating RM started event
        this.monitoring.rmEvent(new RMEvent(RMEventType.STARTED));
        authentication.setActivated(true);
        clientPinger.ping();
        initiateRecoveryIfRequired();
    } catch (ActiveObjectCreationException e) {
        logger.error("", e);
    } catch (NodeException e) {
        logger.error("", e);
    } catch (ProActiveException e) {
        logger.error("", e);
    } catch (ClassNotFoundException e) {
        logger.error("", e);
    } finally {
        signalRMCoreIsInitialized();
    }
    if (logger.isDebugEnabled()) {
        logger.debug("RMCore end: initActivity");
    }
}
Also used : ProbablisticSelectionManager(org.ow2.proactive.resourcemanager.selection.statistics.ProbablisticSelectionManager) ClientPinger(org.ow2.proactive.resourcemanager.utils.ClientPinger) RMMonitoringImpl(org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl) NodeException(org.objectweb.proactive.core.node.NodeException) ProActiveException(org.objectweb.proactive.core.ProActiveException) RMAuthenticationImpl(org.ow2.proactive.resourcemanager.authentication.RMAuthenticationImpl) StubObject(org.objectweb.proactive.core.mop.StubObject) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) NodesCleaner(org.ow2.proactive.resourcemanager.cleaning.NodesCleaner) TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) RMEvent(org.ow2.proactive.resourcemanager.common.event.RMEvent) RMNodeConfigurator(org.ow2.proactive.resourcemanager.nodesource.RMNodeConfigurator)

Example 8 with SelectionManager

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

the class SelectionManagerTest method testSelectNodesWith10Node.

@Test
public void testSelectNodesWith10Node() {
    RMCore rmCore = newMockedRMCore(10);
    SelectionManager selectionManager = createSelectionManager(rmCore);
    Criteria crit = new Criteria(10);
    crit.setTopology(TopologyDescriptor.ARBITRARY);
    crit.setScripts(null);
    crit.setBlackList(null);
    crit.setBestEffort(true);
    Client mockedClient = mock(Client.class);
    NodeSet nodeSet = selectionManager.selectNodes(crit, mockedClient);
    assertEquals(10, nodeSet.size());
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria) Client(org.ow2.proactive.resourcemanager.authentication.Client) Test(org.junit.Test)

Example 9 with SelectionManager

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

the class SelectionManagerTest method selectWithDifferentPermissions.

@Test
public void selectWithDifferentPermissions() throws Exception {
    PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER.updateProperty("10");
    System.out.println("PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER=" + PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER);
    System.setSecurityManager(securityManagerRejectingUser());
    RMCore.topologyManager = mock(TopologyManager.class);
    RMCore rmCore = mock(RMCore.class);
    when(RMCore.topologyManager.getHandler(Matchers.<TopologyDescriptor>any())).thenReturn(selectAllTopology());
    SelectionManager selectionManager = createSelectionManager(rmCore);
    ArrayList<RMNode> freeNodes = new ArrayList<>();
    freeNodes.add(createMockedNode("admin"));
    freeNodes.add(createMockedNode("user"));
    when(rmCore.getFreeNodes()).thenReturn(freeNodes);
    Criteria criteria = new Criteria(2);
    criteria.setTopology(TopologyDescriptor.ARBITRARY);
    Subject subject = Subjects.create("admin");
    NodeSet nodes = selectionManager.selectNodes(criteria, new Client(subject, false));
    assertEquals(1, nodes.size());
}
Also used : TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) ArrayList(java.util.ArrayList) Criteria(org.ow2.proactive.utils.Criteria) Client(org.ow2.proactive.resourcemanager.authentication.Client) Subject(javax.security.auth.Subject) Test(org.junit.Test)

Example 10 with SelectionManager

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

the class SelectionManagerTest method testSelectNodesWith1Node.

@Test
public void testSelectNodesWith1Node() {
    RMCore rmCore = newMockedRMCore(1);
    SelectionManager selectionManager = createSelectionManager(rmCore);
    Criteria crit = new Criteria(1);
    crit.setTopology(TopologyDescriptor.ARBITRARY);
    crit.setScripts(null);
    crit.setBlackList(null);
    crit.setBestEffort(true);
    Client mockedClient = mock(Client.class);
    NodeSet nodeSet = selectionManager.selectNodes(crit, mockedClient);
    assertEquals(1, nodeSet.size());
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria) Client(org.ow2.proactive.resourcemanager.authentication.Client) 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