use of functionaltests.monitor.RMMonitorsHandler in project scheduling by ow2-proactive.
the class TestRMProxyRebind method connectToRM.
private Map.Entry<RMMonitorsHandler, RMMonitorEventReceiver> connectToRM(String rmUrl, Credentials creds) throws Exception {
RMMonitorsHandler monitorsHandler1 = new RMMonitorsHandler();
/**
* create event receiver then turnActive to avoid deepCopy of MonitorsHandler object
* (shared instance between event receiver and static helpers).
*/
RMMonitorEventReceiver passiveEventReceiver = new RMMonitorEventReceiver(monitorsHandler1);
RMMonitorEventReceiver receiver = PAActiveObject.turnActive(passiveEventReceiver);
eventReceivers.add(receiver);
receiver.init(rmUrl, creds);
return new AbstractMap.SimpleImmutableEntry<RMMonitorsHandler, RMMonitorEventReceiver>(monitorsHandler1, receiver);
}
use of functionaltests.monitor.RMMonitorsHandler in project scheduling by ow2-proactive.
the class TestRMProxyRebind method createRMs.
@Before
public void createRMs() throws Exception {
schedulerProxyCredentials = Credentials.getCredentials(PASchedulerProperties.getAbsolutePath(PASchedulerProperties.RESOURCE_MANAGER_CREDS.getValueAsString()));
helper1 = new TestRM();
helper2 = new TestRM();
pnpPort1 = CentralPAPropertyRepository.PA_RMI_PORT.getValue() + 1;
jmxPort1 = PAResourceManagerProperties.RM_JMX_PORT.getValueAsInt() + 1;
pnpPort2 = CentralPAPropertyRepository.PA_RMI_PORT.getValue() + 2;
jmxPort2 = PAResourceManagerProperties.RM_JMX_PORT.getValueAsInt() + 2;
helper1.start(config1.getAbsolutePath(), pnpPort1, RMTHelper.testClasspath(), PAResourceManagerProperties.RM_JMX_PORT.getCmdLine() + jmxPort1);
Credentials connectedUserCreds = Credentials.createCredentials(new CredData(CredData.parseLogin(TestUsers.DEMO.username), CredData.parseDomain(TestUsers.DEMO.username), TestUsers.DEMO.password), helper1.getAuth().getPublicKey());
Map.Entry<RMMonitorsHandler, RMMonitorEventReceiver> entry1 = connectToRM(helper1.getUrl(), connectedUserCreds);
monitorsHandler1 = entry1.getKey();
rm1 = entry1.getValue();
testNodes.addAll(RMTHelper.addNodesToDefaultNodeSource(NODES_NUMBER, new ArrayList<String>(), rm1, monitorsHandler1));
helper2.start(config2.getAbsolutePath(), pnpPort2, RMTHelper.testClasspath(), PAResourceManagerProperties.RM_JMX_PORT.getCmdLine() + jmxPort2);
Map.Entry<RMMonitorsHandler, RMMonitorEventReceiver> entry2 = connectToRM(helper2.getUrl(), connectedUserCreds);
monitorsHandler2 = entry2.getKey();
rm2 = entry2.getValue();
testNodes.addAll(RMTHelper.addNodesToDefaultNodeSource(NODES_NUMBER, new ArrayList<String>(), rm2, monitorsHandler2));
checkFreeNodes(rm1, NODES_NUMBER);
checkFreeNodes(rm2, NODES_NUMBER);
}
use of functionaltests.monitor.RMMonitorsHandler in project scheduling by ow2-proactive.
the class TestSSHInfrastructureV2RestartDownNodesPolicy method testSSHInfrastructureV2WithRestartDownNodes.
@Test
public void testSSHInfrastructureV2WithRestartDownNodes() throws Exception {
nsname = "testSSHInfraRestart";
resourceManager = this.rmHelper.getResourceManager();
RMTHelper.log("Test - Create SSH infrastructure with RestartDownNodes policy on ssh://localhost on port " + TestSSHInfrastructureV2.port);
resourceManager.createNodeSource(nsname, SSHInfrastructureV2.class.getName(), TestSSHInfrastructureV2.infraParams, RestartDownNodesPolicy.class.getName(), TestSSHInfrastructureV2.policyParameters, NODES_NOT_RECOVERABLE);
RMMonitorsHandler monitorsHandler = this.rmHelper.getMonitorsHandler();
this.rmHelper.waitForNodeSourceCreation(nsname, NB_NODES, monitorsHandler);
RMState s = resourceManager.getState();
assertEquals(NB_NODES, s.getTotalNodesNumber());
assertEquals(NB_NODES, s.getFreeNodesNumber());
NodeSet nodeset = resourceManager.getNodes(new Criteria(NB_NODES));
if (nodeset.size() != NB_NODES) {
RMTHelper.log("Illegal state : the infrastructure could not deploy nodes or they died immediately. Ending test");
throw new RuntimeException("Illegal state : the infrastructure could not deploy nodes or they died immediately. Ending test");
}
for (Node n : nodeset) {
rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL(), 60000, monitorsHandler);
}
String nodeUrl = nodeset.get(0).getNodeInformation().getURL();
RMTHelper.log("Killing nodes");
// Nodes will be redeployed only if we kill the whole runtime
rmHelper.killRuntime(nodeUrl);
RMTHelper.log("Wait for down nodes detection by the rm");
for (Node n : nodeset) {
RMNodeEvent ev = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL(), 120000, monitorsHandler);
assertEquals(NodeState.DOWN, ev.getNodeState());
}
for (Node n : nodeset) {
rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n.getNodeInformation().getURL(), 120000, monitorsHandler);
}
RMTHelper.log("Dumping events not consumed yet");
monitorsHandler.dumpEvents();
RMTHelper.log("Wait for nodes restart by the policy");
rmHelper.waitForAnyMultipleNodeEvent(RMEventType.NODE_ADDED, NB_NODES, monitorsHandler);
for (int i = 0; i < NB_NODES; i++) {
rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED, monitorsHandler);
rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED, monitorsHandler);
rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED, monitorsHandler);
}
RMTHelper.log("Final checks on the scheduler state");
nodeset = resourceManager.getNodes(new Criteria(NB_NODES));
for (Node n : nodeset) {
System.out.println("NODE::" + n.getNodeInformation().getURL());
}
s = resourceManager.getState();
assertEquals(NB_NODES, s.getTotalNodesNumber());
// check amount of all nodes that are not down
assertEquals(NB_NODES, s.getTotalAliveNodesNumber());
}
use of functionaltests.monitor.RMMonitorsHandler in project scheduling by ow2-proactive.
the class TestNodeSourceThreadPool method testNodeSourceDeploymentThreadsDoNotLeakWithInfiniteRetry.
@Test
public /*
* This setup makes LOST nodes on one host and FREE nodes on another host.
* We use a configuration of two threads for the nodes deployment, and an
* infrastructure with infinite retry number for deploying. After cycling
* two redeployment phases thanks to the policy, we expect the situation
* to be:
* - one thread being always taken by the infinite retry on the fake host
* - one thread available to deploy with success/redeploy on the localhost
* A timeout is thrown if a thread leak prevents the redeployment to happen
*/
void testNodeSourceDeploymentThreadsDoNotLeakWithInfiniteRetry() throws Exception {
String rmConfig = new File(RMTHelper.class.getResource(SIX_THREADS_CONFIG_FILE_PATH).toURI()).getAbsolutePath();
this.rmHelper.startRM(rmConfig);
this.resourceManager = this.rmHelper.getResourceManager();
this.resourceManager.defineNodeSource(NODE_SOURCE_NAME, SSHInfrastructureV2.class.getName(), getInfiniteRetryInfrastructureParameters(), RestartDownNodesPolicy.class.getName(), getRestartDownNodesPolicyParameters(), NODES_NOT_RECOVERABLE);
this.resourceManager.deployNodeSource(NODE_SOURCE_NAME);
RMTHelper.log("Waiting for the RM to have one free node");
while (this.resourceManager.getState().getFreeNodesNumber() != ONE_NODE_PER_HOST) {
Thread.sleep(ACTIVE_WAITING_PERIOD);
}
assertEquals(1, this.resourceManager.getState().getAliveNodes().size());
for (int i = 0; i < 2; i++) {
String freeNodeUrl = this.resourceManager.getState().getFreeNodes().iterator().next();
RMTHelper.killRuntime(freeNodeUrl);
RMMonitorsHandler monitor = this.rmHelper.getMonitorsHandler();
monitor.flushEvents();
RMTHelper.log("Waiting for the RM to detect the down node");
RMNodeEvent nodeEvent = RMTHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, freeNodeUrl, NODE_STATE_CHANGED_TIMEOUT, monitor);
assertEquals(NodeState.DOWN, nodeEvent.getNodeState());
RMTHelper.log("Waiting for the RM to redeploy the down node");
int totalWaitingTime = 0;
while (this.resourceManager.getState().getFreeNodesNumber() != ONE_NODE_PER_HOST) {
Thread.sleep(ACTIVE_WAITING_PERIOD);
totalWaitingTime += ACTIVE_WAITING_PERIOD;
if (totalWaitingTime > NODE_STATE_CHANGED_TIMEOUT) {
throw new TestTimedOutException(NODE_STATE_CHANGED_TIMEOUT, TimeUnit.MILLISECONDS);
}
}
}
assertEquals(1, this.resourceManager.getState().getAliveNodes().size());
}
use of functionaltests.monitor.RMMonitorsHandler 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));
}
Aggregations