boolean finished = report.isFinished();
ClusterEntity cluster = findByName(report.getName());
Map<String, NodeReport> nodeReportMap = report.getNodeReports();
for (NodeGroupEntity group : cluster.getNodeGroups()) {
for (NodeEntity node : group.getNodes()) {
NodeReport nodeReport = nodeReportMap.get(node.getVmName());
if (nodeReport == null) {
continue;
}
if (nodeReport.getStatus() != null) {
if (!node.isDisconnected()
&& node.getStatus().ordinal() >= NodeStatus.VM_READY
.ordinal()) {
logger.debug("Got node " + node.getVmName() + " status "
+ nodeReport.getStatus().toString());
NodeStatus oldStatus = node.getStatus();
switch (nodeReport.getStatus()) {
case STARTED:
node.setStatus(NodeStatus.SERVICE_READY, false);
break;
case UNHEALTHY:
node.setStatus(NodeStatus.SERVICE_UNHEALTHY, false);
break;
case ALERT:
if (node.getStatus() != NodeStatus.BOOTSTRAP_FAILED) {
node.setStatus(NodeStatus.SERVICE_ALERT, false);
}
break;
case UNKONWN:
node.setStatus(NodeStatus.UNKNOWN, false);
break;
case PROVISIONING:
case STOPPED:
if (node.getStatus() != NodeStatus.BOOTSTRAP_FAILED) {
node.setStatus(NodeStatus.VM_READY, false);
}
break;
default:
node.setStatus(NodeStatus.BOOTSTRAP_FAILED, false);
}
logger.debug("node:" + node.getVmName()
+ ", status changed from old status: " + oldStatus
+ " to new status: " + node.getStatus());
}
}
if (nodeReport.isUseClusterMsg() && report.getAction() != null) {
logger.debug("set node action to:" + report.getAction());
node.setAction(report.getAction());
} else if (nodeReport.getAction() != null) {
node.setAction(nodeReport.getAction());
}
if (lastUpdate) {
if (nodeReport.getErrMsg() != null) {
logger.debug("set node error message to:"
+ report.getAction());
node.setErrMessage(nodeReport.getErrMsg());
node.setActionFailed(true);
} else {
logger.debug("clear node error message for node "
+ node.getHostName());
node.setErrMessage(null);