JsonObject jsonResponse = new JsonObject();
JsonArray data = new JsonArray();
JsonArray row;
DuccDaemonsData duccDaemonsData = DuccDaemonsData.getInstance();
for(DaemonName daemonName : DuccDaemonRuntimeProperties.daemonNames) {
row = new JsonArray();
String status = "";
String heartbeat = "*";
String heartmax = "*";
Properties properties = DuccDaemonRuntimeProperties.getInstance().get(daemonName);
switch(daemonName) {
case Webserver:
status = DuccHandlerUtils.up();
break;
default:
status = DuccHandlerUtils.unknown();
if(daemonName.equals(DaemonName.Orchestrator)) {
if(ComponentHelper.isLocked(IDuccEnv.DUCC_STATE_DIR,"orchestrator")) {
String filename = ComponentHelper.getLockFileName(IDuccEnv.DUCC_STATE_DIR,"orchestrator");
String hover = "title=\""+ComponentHelper.getLockFileNameWithPath(IDuccEnv.DUCC_STATE_DIR,"orchestrator")+"\"";
String fileNameWithHover = "<span "+hover+" >"+filename+"</span>";
status += ", "+DuccHandlerUtils.warn("warning: ")+fileNameWithHover+" found.";
}
}
heartbeat = DuccDaemonsData.getInstance().getHeartbeat(daemonName);
long timeout = getMillisMIA(daemonName)/1000;
if(timeout > 0) {
try {
long overtime = timeout - Long.parseLong(heartbeat);
if(overtime < 0) {
status = DuccHandlerUtils.down();
if(daemonName.equals(DaemonName.Orchestrator)) {
if(ComponentHelper.isLocked(IDuccEnv.DUCC_STATE_DIR,"orchestrator")) {
String filename = ComponentHelper.getLockFileName(IDuccEnv.DUCC_STATE_DIR,"orchestrator");
String hover = "title=\""+ComponentHelper.getLockFileNameWithPath(IDuccEnv.DUCC_STATE_DIR,"orchestrator")+"\"";
String fileNameWithHover = "<span "+hover+" >"+filename+"</span>";
status += ", "+DuccHandlerUtils.warn("warning: ")+fileNameWithHover+" found.";
}
}
}
else {
status = DuccHandlerUtils.up();
if(daemonName.equals(DaemonName.Orchestrator)) {
int jdCount = DuccData.getInstance().getLive().getJobDriverNodeCount();
if(jdCount == 0) {
status = DuccHandlerUtils.up_provisional(", pending JD allocation");
}
}
}
}
catch(Throwable t) {
}
}
heartmax = DuccDaemonsData.getInstance().getMaxHeartbeat(daemonName);
break;
}
// Status
row.add(new JsonPrimitive(status));
// Daemon Name
String name = getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyDaemonName,daemonName.toString());
row.add(new JsonPrimitive(name));
// Boot Time
String boot = getTimeStamp(DuccCookies.getDateStyle(request),getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyBootTime,""));
row.add(new JsonPrimitive(boot));
// Host IP
String ip = getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyNodeIpAddress,"");
row.add(new JsonPrimitive(ip));
// Host Name
String node = getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyNodeName,"");
row.add(new JsonPrimitive(node));
// PID
String pid = getPropertiesValue(properties,DuccDaemonRuntimeProperties.keyPid,"");
row.add(new JsonPrimitive(pid));
// Publication Size (last)
Long pubSize = duccDaemonsData.getEventSize(daemonName);
row.add(new JsonPrimitive(""+pubSize));
// Publication Size (max)
Long pubSizeMax = duccDaemonsData.getEventSizeMax(daemonName);
row.add(new JsonPrimitive(""+pubSizeMax));
// Heartbeat (last)
row.add(new JsonPrimitive(""+heartbeat));
// Heartbeat (max)
row.add(new JsonPrimitive(""+heartmax));