Commit 47b8aad9 authored by Andre Freyssinet's avatar Andre Freyssinet

Adds dumpServerState method.

parent f3959655
......@@ -86,6 +86,46 @@ public class SCServer implements SCServerMBean {
return servers;
}
@Override
public void dumpServerState(String path) {
dumpServerState(path, null);
}
public static void dumpServerState(String path, String cause) {
FileWriter writer = null;
try {
writer = new FileWriter(path, true);
final StringBuffer strbuf = new StringBuffer();
if (cause != null) {
writer.write("\n===== Dump cause =====\n\n");
writer.write(cause);
writer.write("\n");
}
writer.write("\n===== MBean's attributes =====\n\n");
DumpAttributes.dumpAttributes("*:*", strbuf);
writer.write(strbuf.toString());
writer.flush();
strbuf.setLength(0);
writer.write("\n===== Thread's stack traces =====\n\n");
DumpAttributes.dumpAllStackTraces(strbuf);
writer.write(strbuf.toString());
writer.flush();
strbuf.setLength(0);
} catch (IOException exc) {
logger.log(BasicLevel.ERROR,
"MqttCheckActivator.dumpServerState, cannot open dump file \"" + path + "\"", exc);
} finally {
if (writer != null)
try {
writer.close();
} catch (IOException e) {}
}
}
public void dumpAttributes(String name, String path, boolean threaddump) {
FileWriter writer = null;
try {
......
......@@ -33,5 +33,6 @@ public interface SCServerMBean {
public String[] getServers();
public void dumpServerState(String path);
public void dumpAttributes(String name, String path, boolean threaddump);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment