Search in sources :

Example 1 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.

the class SelectionManagerTest method newMockedRMCore.

public static RMCore newMockedRMCore(int nbNodes) {
    RMCore mockedRMCore = Mockito.mock(RMCore.class);
    TopologyManager mockedTopologyManager = Mockito.mock(TopologyManager.class);
    when(mockedTopologyManager.getHandler(Matchers.any(TopologyDescriptor.class))).thenReturn(selectAllTopology());
    RMCore.topologyManager = mockedTopologyManager;
    if (nbNodes > 0) {
        ArrayList<RMNode> freeNodes = new ArrayList<RMNode>(nbNodes);
        for (int i = 0; i < nbNodes; i++) {
            freeNodes.add(createMockeNode("user", "mocked-node-" + (i + 1), "mocked-node-" + (i + 1)));
        }
        when(mockedRMCore.getFreeNodes()).thenReturn(freeNodes);
    }
    return mockedRMCore;
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) ArrayList(java.util.ArrayList) TopologyDescriptor(org.ow2.proactive.topology.descriptor.TopologyDescriptor)

Example 2 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore 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 3 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore 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 4 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore 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 5 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore 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)

Aggregations

Test (org.junit.Test)17 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)11 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)8 Criteria (org.ow2.proactive.utils.Criteria)8 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)7 Client (org.ow2.proactive.resourcemanager.authentication.Client)7 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)7 NodeSet (org.ow2.proactive.utils.NodeSet)7 RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)6 Node (org.objectweb.proactive.core.node.Node)5 MutableInteger (org.objectweb.proactive.core.util.MutableInteger)5 RMException (org.ow2.proactive.resourcemanager.exception.RMException)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Matchers.anyString (org.mockito.Matchers.anyString)4 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)4 TopologyManager (org.ow2.proactive.resourcemanager.selection.topology.TopologyManager)4 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)3 KeyException (java.security.KeyException)3 HashMap (java.util.HashMap)3