ClusterEntity cluster = clusterEntityMgr.findByName(clusterName);
if (cluster == null) {
logger.error("cluster " + clusterName + " does not exist");
throw BddException.NOT_FOUND("Cluster", clusterName);
}
SoftwareManager softMgr =
softwareManagerCollector
.getSoftwareManager(cluster.getAppManager());
ValidationUtils.validateVersion(clusterEntityMgr, clusterName);
ClusterStatus oldStatus = cluster.getStatus();
if (!oldStatus.isActiveServiceStatus()) {
throw ClusterHealServiceException.NOT_SUPPORTED(clusterName,
"The cluster status must be RUNNING");
}
List<NodeGroupEntity> nodeGroups;
if (groupName != null) {
NodeGroupEntity nodeGroup =
clusterEntityMgr.findByName(clusterName, groupName);
if (nodeGroup == null) {
logger.error("node group " + groupName + " does not exist");
throw BddException.NOT_FOUND("group", groupName);
}
nodeGroups = new ArrayList<NodeGroupEntity>(1);
nodeGroups.add(nodeGroup);
} else {
nodeGroups = clusterEntityMgr.findAllGroups(clusterName);
}
// only fix worker nodes that have datanode or tasktracker roles
boolean workerNodesFound = false;
JobParametersBuilder parametersBuilder = new JobParametersBuilder();
List<JobParameters> jobParameterList = new ArrayList<JobParameters>();
for (NodeGroupEntity nodeGroup : nodeGroups) {
List<String> roles = nodeGroup.getRoleNameList();
// TODO: more fine control on node roles
if (softMgr.hasMgmtRole(roles)) {
logger.info("node group " + nodeGroup.getName()
+ " contains management roles, pass it");
continue;
}