public static String createStatusDump(org.xmlBlaster.engine.ServerScope g,
String summary, String description,
String eventType, String errorCode) {
// Change to be configurable with ${amdincommands} replacements
RequestBroker r = g.getRequestBroker();
XmlBuffer buf = new XmlBuffer(10000);
//buf.append("\n").append("<xmlBlaster>"); // Root tag not added, so we easily can collect different nodes to a big xml dump
buf.append("\n ").append("<node id='").appendEscaped(g.getId()).append("'>");
if (summary != null)
buf.append("\n ").append("<_summary>").appendEscaped(summary).append("</_summary>");
if (description != null)
buf.append("\n ").append("<_description>").appendEscaped(description).append("</_description>");
if (eventType != null)
buf.append("\n ").append("<_eventType>").append(eventType).append("</_eventType>");
if (errorCode != null)
buf.append("\n ").append("<_errorCode>").append(errorCode).append("</_errorCode>");
buf.append("\n ").append("<uptime>").append(r.getUptime()).append("</uptime>");
buf.append("\n ").append("<runlevel>").append(g.getRunlevelManager().getCurrentRunlevel()).append("</runlevel>");
buf.append("\n ").append("<instanceId>").appendEscaped(g.getInstanceId()).append("</instanceId>");
buf.append("\n ").append("<version>").append(g.getVersion()).append("</version>");
buf.append("\n ").append("<revisionNumber>").append(g.getRevisionNumber()).append("</revisionNumber>");
buf.append("\n ").append("<freeMem>").append(r.getFreeMem()).append("</freeMem>");
buf.append("\n ").append("<maxFreeMem>").append(r.getMaxFreeMem()).append("</maxFreeMem>");
buf.append("\n ").append("<maxMem>").append(r.getMaxMem()).append("</maxMem>");
buf.append("\n ").append("<usedMem>").append(r.getUsedMem()).append("</usedMem>");
buf.append("\n ").append("<serverTimestamp>").append(new java.sql.Timestamp(new java.util.Date().getTime()).toString()).append("</serverTimestamp>");
buf.append("\n ").append("<numClients>").append(r.getNumClients()).append("</numClients>");
buf.append("\n ").append("<clientList>").appendEscaped(r.getClientList()).append("</clientList>");
SubjectInfo[] clients = r.getAuthenticate().getSubjectInfoArr();
for (int c=0; c<clients.length; c++) {
SubjectInfo subjectInfo = clients[c];
if (subjectInfo.getLoginName().startsWith("__")) continue;// Ignore internal sessions
buf.append("\n ").append("<client id='").appendEscaped(subjectInfo.getLoginName()).append("'>");
SessionInfo[] sessions = subjectInfo.getSessions();
for (int s=0; s<sessions.length; s++) {
SessionInfo sessionInfo = sessions[s];
buf.append("\n ").append("<session id='").append(sessionInfo.getPublicSessionId()).append("'>");
buf.append("\n ").append("<state>").append(sessionInfo.getConnectionState()).append("</state>");
ClientProperty[] props = sessionInfo.getRemotePropertyArr();
for (int p=0; p<props.length; p++)
buf.append(props[p].toXml(" ", "remoteProperty", true));
I_Queue sessionQueue = sessionInfo.getSessionQueue();
if (sessionQueue != null) {
buf.append("\n <queue relating='callback'");
buf.append(" numOfEntries='").append(sessionQueue.getNumOfEntries()).append("'");
buf.append(" numOfBytes='").append(sessionQueue.getNumOfBytes()).append("'");
buf.append("/>");
//buf.append(sessionQueue.toXml("\n "));
}
buf.append(sessionInfo.getDispatchStatistic().toXml(" "));
buf.append("\n ").append("</session>");
}
buf.append("\n ").append("</client>");
}
ClusterManager clusterManager = g.getClusterManagerNoEx();
if (clusterManager != null && clusterManager.isReady()) {
ClusterNode[] nodes = clusterManager.getClusterNodes();
for (int ic = 0; ic < nodes.length; ic++) {
ClusterNode node = nodes[ic];
SessionName destination = node.getRemoteSessionName();
if (destination == null)
continue;
buf.append("\n ").append("<connection clusterId='").appendEscaped(destination.getNodeIdStr()).append(
"' id='").appendEscaped(destination.getLoginName()).append("'>");
buf.append("\n ").append("<session id='").append(destination.getPublicSessionId()).append("'>");
buf.append("\n ").append("<state>").append(node.getConnectionStateStr()).append("</state>");
I_Queue clientQueue = node.getConnectionQueue();
if (clientQueue != null) {
buf.append("\n <queue relating='" + Constants.RELATING_CLIENT + "'"); // "connection"
buf.append(" numOfEntries='").append(clientQueue.getNumOfEntries()).append("'");
buf.append(" maxNumOfEntries='").append(clientQueue.getMaxNumOfEntries()).append("'");
buf.append(" numOfBytes='").append(clientQueue.getNumOfBytes()).append("'");
buf.append(" maxNumOfBytes='").append(clientQueue.getMaxNumOfBytes()).append("'");
buf.append("/>");
}
// buf.append(clientQueue.getDispatchStatistic().toXml(" "));
buf.append("\n ").append("</session>");
buf.append("\n ").append("</connection>");
}
}
buf.append("\n ").append("<numTopics>").append(r.getNumTopics()).append("</numTopics>");
buf.append("\n ").append("<topicList>").appendEscaped(r.getTopicList()).append("</topicList>");
buf.append("\n ").append("<numGet>").append(r.getNumGet()).append("</numGet>");
buf.append("\n ").append("<numPublish>").append(r.getNumPublish()).append("</numPublish>");
buf.append("\n ").append("<numUpdate>").append(r.getNumUpdate()).append("</numUpdate>");
// " encoding='base64'" if string contains CDATA?
String warning = ReplaceVariable.replaceAll(r.getLastWarning(), "<![CDATA[", "<![CDATA[");
warning = ReplaceVariable.replaceAll(warning, "]]>", "]]>");
String error = ReplaceVariable.replaceAll(r.getLastError(), "<![CDATA[", "<![CDATA[");
error = ReplaceVariable.replaceAll(error, "]]>", "]]>");
buf.append("\n ").append("<lastWarning><![CDATA[").append(warning).append("]]></lastWarning>");
buf.append("\n ").append("<lastError><![CDATA[").append(error).append("]]></lastError>");
XmlBlasterException e = new XmlBlasterException(g,
ErrorCode.COMMUNICATION_NOCONNECTION, ME, "");
buf.append("\n ").append("<versionInfo><![CDATA[").appendEscaped(e.getVersionInfo()).append("]]></versionInfo>");
buf.append("\n ").append("<see>").append("http://www.xmlBlaster.org/xmlBlaster/doc/requirements/admin.events.html").append("</see>");
buf.append("\n ").append("</node>");
//buf.append("\n").append("</xmlBlaster>");
return buf.toString();
}