Assert.assertNotNull(groupId);
// Install
Long requestId = installService(clusterName, serviceName1, false, false);
HostRoleCommand namenodeInstall = null;
HostRoleCommand clientInstall = null;
HostRoleCommand slaveInstall = null;
for (Stage stage : actionDB.getAllStages(requestId)) {
for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
if (hrc.getRole().equals(Role.NAMENODE) && hrc.getHostName().equals("h1")) {
namenodeInstall = hrc;
} else if (hrc.getRole().equals(Role.HDFS_CLIENT) && hrc.getHostName()
.equals("h3")) {
clientInstall = hrc;
} else if (hrc.getRole().equals(Role.DATANODE) && hrc.getHostName()
.equals("h2")) {
slaveInstall = hrc;
}
}
}
Assert.assertNotNull(namenodeInstall);
Assert.assertNotNull(clientInstall);
Assert.assertNotNull(slaveInstall);
Assert.assertTrue(namenodeInstall.getExecutionCommandWrapper()
.getExecutionCommand().getConfigurations().get("core-site").containsKey("a"));
Assert.assertEquals("c", namenodeInstall.getExecutionCommandWrapper()
.getExecutionCommand().getConfigurations().get("core-site").get("a"));
// Slave and client should not have the override
Assert.assertTrue(clientInstall.getExecutionCommandWrapper()
.getExecutionCommand().getConfigurations().get("core-site").containsKey("a"));
Assert.assertEquals("b", clientInstall.getExecutionCommandWrapper()
.getExecutionCommand().getConfigurations().get("core-site").get("a"));
Assert.assertTrue(slaveInstall.getExecutionCommandWrapper()
.getExecutionCommand().getConfigurations().get("core-site").containsKey("a"));
Assert.assertEquals("b", slaveInstall.getExecutionCommandWrapper()
.getExecutionCommand().getConfigurations().get("core-site").get("a"));
startService(clusterName, serviceName1, false, false);
requestId = installService(clusterName, serviceName2, false, false);
HostRoleCommand mapredInstall = null;
for (Stage stage : actionDB.getAllStages(requestId)) {
for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
if (hrc.getRole().equals(Role.HISTORYSERVER) && hrc.getHostName()
.equals("h3")) {
mapredInstall = hrc;
}
}
}
Assert.assertNotNull(mapredInstall);
// Config group not associated with host
Assert.assertEquals("b", mapredInstall.getExecutionCommandWrapper()
.getExecutionCommand().getConfigurations().get("mapred-site").get("a"));
// Associate the right host
ConfigGroup configGroup = cluster.getConfigGroups().get(groupId);
configGroup.setHosts(new HashMap<String, Host>() {{ put("h3",
clusters.getHost("h3")); }});
configGroup.persist();
requestId = startService(clusterName, serviceName2, false, false);
mapredInstall = null;
for (Stage stage : actionDB.getAllStages(requestId)) {
for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
if (hrc.getRole().equals(Role.HISTORYSERVER) && hrc.getHostName()
.equals("h3")) {
mapredInstall = hrc;
}
}
}
Assert.assertNotNull(mapredInstall);
Assert.assertEquals("c", mapredInstall.getExecutionCommandWrapper()
.getExecutionCommand().getConfigurations().get("mapred-site").get("a"));
}