Cluster cluster = clusters.getCluster("c1");
cluster.setDesiredStackVersion(new StackId("HDP-2.0.7"));
cluster.setCurrentStackVersion(new StackId("HDP-2.0.7"));
Service hdfs = cluster.addService("HDFS");
hdfs.persist();
hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
hdfs.addServiceComponent(Role.DATANODE.name()).persist();
hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost("h1").persist();
hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost("h1").persist();
hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h1").persist();
Service nagios = cluster.addService("NAGIOS");
nagios.persist();
nagios.addServiceComponent(Role.NAGIOS_SERVER.name()).persist();
nagios.getServiceComponent(Role.NAGIOS_SERVER.name()).addServiceComponentHost("h1").persist();
installService("c1", "HDFS", false, false);
installService("c1", "NAGIOS", false, false);
startService("c1", "HDFS", false, false);
startService("c1", "NAGIOS", false, false);
// set this after starting - setting it before will skip it due to rules
// around bulk starts
hdfs.getServiceComponent(Role.DATANODE.name()).getServiceComponentHost(
"h1").setMaintenanceState(MaintenanceState.ON);
Cluster c = clusters.getCluster("c1");
Service s = c.getService("HDFS");
Assert.assertEquals(State.STARTED, s.getDesiredState());
for (ServiceComponent sc : s.getServiceComponents().values()) {
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
if (sc.isClientComponent()) {
Assert.assertEquals(State.INSTALLED, sch.getDesiredState());
} else {
Assert.assertEquals(State.STARTED, sch.getDesiredState());