Cluster cluster = domain.getClusterForInstance(name);
String clusterName = (cluster != null) ? cluster.getName() : null;
// skip DAS
if (notDas(name)) {
ActionReport tReport = habitat.getComponent(ActionReport.class, "html");
InstanceInfo ii = new InstanceInfo(
habitat,
server,
port,
host,
clusterName,
logger,
timeoutInMsec,
tReport,
stateService);
infos.add(ii);
}
}
if (infos.size() < 1) {
report.setMessage(NONE);
return;
}
Properties extraProps = new Properties();
List instanceList = new ArrayList();
for (InstanceInfo ii : infos) {
String name = ii.getName();
String value = (ii.isRunning()) ? InstanceState.StateType.RUNNING.getDescription()
: InstanceState.StateType.NOT_RUNNING.getDescription();
InstanceState.StateType state = (ii.isRunning())
? (stateService.setState(name, InstanceState.StateType.RUNNING, false))
: (stateService.setState(name, InstanceState.StateType.NOT_RUNNING, false));
List<String> failedCmds = stateService.getFailedCommands(name);
if (state == InstanceState.StateType.RESTART_REQUIRED) {
if (ii.isRunning()) {
//value += (";" + InstanceState.StateType.RESTART_REQUIRED.getDescription());
value = InstanceState.StateType.RESTART_REQUIRED.getDescription();
}
}
HashMap<String, Object> insDetails = new HashMap<String, Object>();
insDetails.put("name", name);
insDetails.put("status", value);
if (state == InstanceState.StateType.RESTART_REQUIRED) {
insDetails.put("restartReasons", failedCmds);
}
if (ii.isRunning()) {
insDetails.put("uptime", ii.getUptime());
}
instanceList.add(insDetails);
}
extraProps.put("instanceList", instanceList);
report.setExtraProperties(extraProps);