ServiceComponentHost componentHost = namenodes.get("host1");
Map<String, ServiceComponentHost> hostComponents = cluster.getService("HDFS").getServiceComponent("DATANODE").getServiceComponentHosts();
for (Map.Entry<String, ServiceComponentHost> entry : hostComponents.entrySet()) {
ServiceComponentHost cHost = entry.getValue();
cHost.handleEvent(new ServiceComponentHostInstallEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis(), "HDP-1.2.0"));
cHost.handleEvent(new ServiceComponentHostOpSucceededEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis()));
}
hostComponents = cluster.getService("HDFS").getServiceComponent("NAMENODE").getServiceComponentHosts();
for (Map.Entry<String, ServiceComponentHost> entry : hostComponents.entrySet()) {
ServiceComponentHost cHost = entry.getValue();
cHost.handleEvent(new ServiceComponentHostInstallEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis(), "HDP-1.2.0"));
cHost.handleEvent(new ServiceComponentHostOpSucceededEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis()));
}
hostComponents = cluster.getService("HDFS").getServiceComponent("SECONDARY_NAMENODE").getServiceComponentHosts();
for (Map.Entry<String, ServiceComponentHost> entry : hostComponents.entrySet()) {
ServiceComponentHost cHost = entry.getValue();
cHost.handleEvent(new ServiceComponentHostInstallEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis(), "HDP-1.2.0"));
cHost.handleEvent(new ServiceComponentHostOpSucceededEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis()));
}
componentHostRequests.clear();
componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", null, "MAINTENANCE"));
amc.updateHostComponents(componentHostRequests, mapRequestProps, true);
assertEquals(State.MAINTENANCE, componentHost.getState());
componentHostRequests.clear();
componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", null, "INSTALLED"));
amc.updateHostComponents(componentHostRequests, mapRequestProps, true);
assertEquals(State.INSTALLED, componentHost.getState());
componentHostRequests.clear();
componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", null, "MAINTENANCE"));
amc.updateHostComponents(componentHostRequests, mapRequestProps, true);
assertEquals(State.MAINTENANCE, componentHost.getState());
componentHostRequests.clear();
componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host2", null, null));
amc.createHostComponents(componentHostRequests);
componentHostRequests.clear();
componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host2", null, "INSTALLED"));
amc.updateHostComponents(componentHostRequests, mapRequestProps, true);
namenodes = cluster.getService("HDFS").getServiceComponent("NAMENODE").getServiceComponentHosts();
assertEquals(2, namenodes.size());
componentHost = namenodes.get("host2");
componentHost.handleEvent(new ServiceComponentHostInstallEvent(componentHost.getServiceComponentName(), componentHost.getHostName(), System.currentTimeMillis(), "HDP-1.2.0"));
componentHost.handleEvent(new ServiceComponentHostOpSucceededEvent(componentHost.getServiceComponentName(), componentHost.getHostName(), System.currentTimeMillis()));
serviceRequests.clear();
serviceRequests.add(new ServiceRequest("c1", "HDFS", null, "STARTED"));