});
}
protected void addHistoryServer() {
ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
List<ClusterEntity> clusterEntities = clusterDAO.findAll();
for (final ClusterEntity clusterEntity : clusterEntities) {
ServiceComponentDesiredStateEntityPK pkHS = new ServiceComponentDesiredStateEntityPK();
pkHS.setComponentName("HISTORYSERVER");
pkHS.setClusterId(clusterEntity.getClusterId());
pkHS.setServiceName("MAPREDUCE");
ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntityHS = serviceComponentDesiredStateDAO.findByPK(pkHS);
// already have historyserver
if(serviceComponentDesiredStateEntityHS != null)
continue;
ServiceComponentDesiredStateEntityPK pkJT = new ServiceComponentDesiredStateEntityPK();
pkJT.setComponentName("JOBTRACKER");
pkJT.setClusterId(clusterEntity.getClusterId());
pkJT.setServiceName("MAPREDUCE");
ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntityJT = serviceComponentDesiredStateDAO.findByPK(pkJT);
// no jobtracker present probably mapreduce is not installed
if(serviceComponentDesiredStateEntityJT == null)
continue;
HostComponentStateEntity jtHostComponentStateEntity = serviceComponentDesiredStateEntityJT.getHostComponentStateEntities().iterator().next();
HostComponentDesiredStateEntity jtHostComponentDesiredStateEntity = serviceComponentDesiredStateEntityJT.getHostComponentDesiredStateEntities().iterator().next();
String jtHostname = jtHostComponentStateEntity.getHostName();
State jtCurrState = jtHostComponentStateEntity.getCurrentState();
State jtHostComponentDesiredState = jtHostComponentDesiredStateEntity.getDesiredState();
State jtServiceComponentDesiredState = serviceComponentDesiredStateEntityJT.getDesiredState();
ClusterServiceEntityPK pk = new ClusterServiceEntityPK();
pk.setClusterId(clusterEntity.getClusterId());
pk.setServiceName("MAPREDUCE");
ClusterServiceEntity clusterServiceEntity = clusterServiceDAO.findByPK(pk);
final ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity = new ServiceComponentDesiredStateEntity();
serviceComponentDesiredStateEntity.setComponentName("HISTORYSERVER");
serviceComponentDesiredStateEntity.setDesiredStackVersion(clusterEntity.getDesiredStackVersion());