long requestId2 = startService(clusterName, serviceName1, true, true);
long requestId3 = startService(clusterName, serviceName2, true, true);
stages = actionDB.getAllStages(requestId2);
stages.addAll(actionDB.getAllStages(requestId3));
HostRoleCommand hdfsCmdHost3 = null;
HostRoleCommand hdfsCmdHost2 = null;
HostRoleCommand mapRedCmdHost2 = null;
HostRoleCommand mapRedCmdHost3 = null;
for (Stage stage : stages) {
List<HostRoleCommand> hrcs = stage.getOrderedHostRoleCommands();
for (HostRoleCommand hrc : hrcs) {
LOG.debug("role: " + hrc.getRole());
if (hrc.getRole().toString().equals("HDFS_CLIENT")) {
if (hrc.getHostName().equals(host3))
hdfsCmdHost3 = hrc;
else if (hrc.getHostName().equals(host2))
hdfsCmdHost2 = hrc;
}
if (hrc.getRole().toString().equals("MAPREDUCE_CLIENT")) {
if (hrc.getHostName().equals(host2))
mapRedCmdHost2 = hrc;
else if (hrc.getHostName().equals(host3))
mapRedCmdHost3 = hrc;
}
}
}
Assert.assertNotNull(hdfsCmdHost3);
Assert.assertNotNull(hdfsCmdHost2);
ExecutionCommand execCmd = hdfsCmdHost3.getExecutionCommandWrapper()
.getExecutionCommand();
Assert.assertEquals(2, execCmd.getConfigurationTags().size());
Assert.assertEquals("version122", execCmd.getConfigurationTags().get
("core-site").get("tag"));
Assert.assertEquals("d", execCmd.getConfigurations().get("core-site")
.get("c"));
// Check if MapReduce client is reinstalled
Assert.assertNotNull(mapRedCmdHost2);
Assert.assertNotNull(mapRedCmdHost3);
/**
* Test for lost host
*/
// Stop HDFS & MAPREDUCE
stopService(clusterName, serviceName1, false, false);
stopService(clusterName, serviceName2, false, false);
clusters.getHost(host2).setState(HostState.HEARTBEAT_LOST);
// Start
requestId2 = startService(clusterName, serviceName1, true, true);
requestId3 = startService(clusterName, serviceName2, true, true);
stages = actionDB.getAllStages(requestId2);
stages.addAll(actionDB.getAllStages(requestId3));
HostRoleCommand clientWithHostDown = null;
for (Stage stage : stages) {
for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
if (hrc.getRole().toString().equals("MAPREDUCE_CLIENT") && hrc
.getHostName().equals(host2))
clientWithHostDown = hrc;