Search in sources :

Example 11 with RMMonitorEventReceiver

use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.

the class NodesRecoveryPropertyTest method restartRmAndCheckFinalState.

private void restartRmAndCheckFinalState(String rmConfigPath, boolean nodesShouldBeRecreated) throws Exception {
    // restart RM
    rmHelper = new RMTHelper();
    startRmWithConfig(rmConfigPath);
    assertThat(PAResourceManagerProperties.RM_PRESERVE_NODES_ON_SHUTDOWN.getValueAsBoolean()).isFalse();
    assertThat(rmHelper.isRMStarted()).isTrue();
    // re-snapshot the RM state
    RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) resourceManager;
    List<RMNodeSourceEvent> nodeSourceEvent = resourceManagerMonitor.getInitialState().getNodeSourceEvents();
    // the node source has been recovered on restart: we should have one node source with the same name
    if (PAResourceManagerProperties.RM_NODES_RECOVERY.getValueAsBoolean()) {
        assertThat(nodeSourceEvent.size()).isEqualTo(1);
    }
    assertThat(nodeSourceEvent.get(0).getSourceName()).isEqualTo(NODE_SOURCE_NAME);
    // wait for nodes to be recreated if needed
    if (nodesShouldBeRecreated) {
        rmHelper.waitForAnyMultipleNodeEvent(RMEventType.NODE_STATE_CHANGED, NODE_NUMBER);
    }
    // the nodes should have been recovered too, and should be alive
    Set<String> allNodes = resourceManagerMonitor.getState().getAllNodes();
    assertThat(allNodes.size()).isEqualTo(NODE_NUMBER);
    Set<String> nodeSourceNames = new HashSet<>();
    nodeSourceNames.add(NODE_SOURCE_NAME);
    Set<String> aliveNodeUrls = resourceManager.listAliveNodeUrls(nodeSourceNames);
    assertThat(aliveNodeUrls.size()).isEqualTo(NODE_NUMBER);
    // the recovered nodes should be usable, try to lock/unlock them to see
    BooleanWrapper lockSucceeded = resourceManager.lockNodes(allNodes);
    assertThat(lockSucceeded).isEqualTo(new BooleanWrapper(true));
    BooleanWrapper unlockSucceeded = resourceManager.unlockNodes(allNodes);
    assertThat(unlockSucceeded).isEqualTo(new BooleanWrapper(true));
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMTHelper(functionaltests.utils.RMTHelper) RMMonitorEventReceiver(functionaltests.monitor.RMMonitorEventReceiver) HashSet(java.util.HashSet)

Example 12 with RMMonitorEventReceiver

use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.

the class RecoverSSHInfrastructureV2Test method restartRmAndCheckFinalState.

private void restartRmAndCheckFinalState(boolean nodesShouldBeRecreated) throws Exception {
    // restart RM
    rmHelper = new RMTHelper();
    startRmWithConfig(RESTART_CONFIG);
    assertThat(PAResourceManagerProperties.RM_PRESERVE_NODES_ON_SHUTDOWN.getValueAsBoolean()).isFalse();
    assertThat(rmHelper.isRMStarted()).isTrue();
    // re-snapshot the RM state
    RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) resourceManager;
    List<RMNodeSourceEvent> nodeSourceEvent = resourceManagerMonitor.getInitialState().getNodeSourceEvents();
    // the node source has been recovered on restart: we should have one node source with the same name
    assertThat(nodeSourceEvent.size()).isEqualTo(1);
    assertThat(nodeSourceEvent.get(0).getSourceName()).isEqualTo(NODE_SOURCE_NAME);
    // wait for nodes to be recreated if needed
    if (nodesShouldBeRecreated) {
        rmHelper.waitForAnyMultipleNodeEvent(RMEventType.NODE_STATE_CHANGED, TestSSHInfrastructureV2.NB_NODES);
    }
    // the nodes should have been recovered too, and should be alive
    Set<String> allNodes = resourceManagerMonitor.getState().getAllNodes();
    assertThat(allNodes.size()).isEqualTo(TestSSHInfrastructureV2.NB_NODES);
    Set<String> nodeSourceNames = new HashSet<>();
    nodeSourceNames.add(NODE_SOURCE_NAME);
    Set<String> aliveNodeUrls = resourceManager.listAliveNodeUrls(nodeSourceNames);
    assertThat(aliveNodeUrls.size()).isEqualTo(TestSSHInfrastructureV2.NB_NODES);
    // the recovered nodes should be usable, try to lock/unlock them to see
    BooleanWrapper lockSucceeded = resourceManager.lockNodes(allNodes);
    assertThat(lockSucceeded).isEqualTo(new BooleanWrapper(true));
    BooleanWrapper unlockSucceeded = resourceManager.unlockNodes(allNodes);
    assertThat(unlockSucceeded).isEqualTo(new BooleanWrapper(true));
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMTHelper(functionaltests.utils.RMTHelper) RMMonitorEventReceiver(functionaltests.monitor.RMMonitorEventReceiver) HashSet(java.util.HashSet)

Example 13 with RMMonitorEventReceiver

use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.

the class RecoverSSHInfrastructureV2Test method startRmAndCheckInitialState.

private void startRmAndCheckInitialState() throws Exception {
    // start RM
    startRmWithConfig(START_CONFIG);
    assertThat(PAResourceManagerProperties.RM_PRESERVE_NODES_ON_SHUTDOWN.getValueAsBoolean()).isTrue();
    assertThat(rmHelper.isRMStarted()).isTrue();
    // check the initial state of the RM
    assertThat(resourceManager.getState().getAllNodes().size()).isEqualTo(0);
    resourceManager.createNodeSource(NODE_SOURCE_NAME, SSHInfrastructureV2.class.getName(), TestSSHInfrastructureV2.infraParams, StaticPolicy.class.getName(), TestSSHInfrastructureV2.policyParameters, NODES_RECOVERABLE);
    RMTHelper.waitForNodeSourceCreation(NODE_SOURCE_NAME, TestSSHInfrastructureV2.NB_NODES, this.rmHelper.getMonitorsHandler());
    RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) resourceManager;
    List<RMNodeSourceEvent> nodeSourceEvent = resourceManagerMonitor.getInitialState().getNodeSourceEvents();
    assertThat(nodeSourceEvent.size()).isEqualTo(1);
    assertThat(nodeSourceEvent.get(0).getSourceName()).isEqualTo(NODE_SOURCE_NAME);
    assertThat(resourceManagerMonitor.getState().getAllNodes().size()).isEqualTo(TestSSHInfrastructureV2.NB_NODES);
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) StaticPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy) TestSSHInfrastructureV2(functionaltests.nodesource.TestSSHInfrastructureV2) SSHInfrastructureV2(org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructureV2) RMMonitorEventReceiver(functionaltests.monitor.RMMonitorEventReceiver)

Example 14 with RMMonitorEventReceiver

use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.

the class RMFunctionalTest method cleanState.

/**
 * Remove all node sources and nodes in the RM
 *
 * @throws Exception
 */
private void cleanState() throws Exception {
    if (rmHelper.isRMStarted()) {
        // force reconnection
        rmHelper.disconnect();
        ResourceManager rm = rmHelper.getResourceManager();
        int nodeNumber = rm.getState().getTotalNodesNumber();
        RMInitialState state = ((RMMonitorEventReceiver) rmHelper.getResourceManager()).getInitialState();
        for (RMNodeSourceEvent sourceEvent : state.getNodeSourceEvents()) {
            String nodeSource = sourceEvent.getSourceName();
            rm.removeNodeSource(nodeSource, true);
            rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, nodeSource);
        }
        for (int i = 0; i < nodeNumber; i++) {
            rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED);
        }
    }
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) RMInitialState(org.ow2.proactive.resourcemanager.common.event.RMInitialState) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMMonitorEventReceiver(functionaltests.monitor.RMMonitorEventReceiver)

Example 15 with RMMonitorEventReceiver

use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.

the class RMTestUser method connect.

public void connect(TestUsers user, String rmUrl) throws RMException, KeyException, LoginException, ActiveObjectCreationException, NodeException {
    this.connectedUserName = user.username;
    this.connectedUserPassword = user.password;
    this.rmUrl = rmUrl;
    disconnectFromRM();
    if (rmProxy == null) {
        monitorsHandler = new RMMonitorsHandler();
        RMMonitorEventReceiver passiveEventReceiver = new RMMonitorEventReceiver(monitorsHandler);
        rmProxy = PAActiveObject.turnActive(passiveEventReceiver);
        RMTHelper.log("RM Proxy initialized : " + PAActiveObject.getUrl(rmProxy));
    }
    RMTHelper.log("Connecting user " + connectedUserName + " to the Resource Manager at " + rmUrl);
    CredData credData = new CredData(CredData.parseLogin(connectedUserName), CredData.parseDomain(connectedUserName), connectedUserPassword);
    // this is to prevent starting working with the rmProxy on the calling
    // thread whereas it has not finished to be initialized
    PAFuture.waitFor(rmProxy.init(rmUrl, credData));
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) RMMonitorEventReceiver(functionaltests.monitor.RMMonitorEventReceiver) RMMonitorsHandler(functionaltests.monitor.RMMonitorsHandler)

Aggregations

RMMonitorEventReceiver (functionaltests.monitor.RMMonitorEventReceiver)15 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)8 HashSet (java.util.HashSet)4 RMMonitorsHandler (functionaltests.monitor.RMMonitorsHandler)3 RMTHelper (functionaltests.utils.RMTHelper)3 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)3 RMInitialState (org.ow2.proactive.resourcemanager.common.event.RMInitialState)3 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)2 Test (org.junit.Test)2 CredData (org.ow2.proactive.authentication.crypto.CredData)2 TestSSHInfrastructureV2 (functionaltests.nodesource.TestSSHInfrastructureV2)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 After (org.junit.After)1 Before (org.junit.Before)1 PAActiveObject (org.objectweb.proactive.api.PAActiveObject)1 Credentials (org.ow2.proactive.authentication.crypto.Credentials)1 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)1 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)1