use of org.jumpmind.symmetric.transport.ConcurrentConnectionManager.NodeConnectionStatistics in project symmetric-ds by JumpMind.
the class NodeManagementService method getNodeConcurrencyStatisticsAsText.
@ManagedAttribute(description = "Get connection statistics about indivdual nodes")
public String getNodeConcurrencyStatisticsAsText() {
String lineFeed = "\n";
if (engine.getParameterService().getString(ParameterConstants.JMX_LINE_FEED).equals("html")) {
lineFeed = "</br>";
}
Map<String, Map<String, NodeConnectionStatistics>> stats = engine.getConcurrentConnectionManager().getNodeConnectionStatisticsByPoolByNodeId();
StringBuilder out = new StringBuilder();
for (String pool : stats.keySet()) {
out.append("-------------------------------------------------------------------------------------------------------------------------------");
out.append(lineFeed);
out.append(" CONNECTION TYPE: ");
out.append(pool);
out.append(lineFeed);
out.append("-------------------------------------------------------------------------------------------------------------------------------");
out.append(lineFeed);
out.append(" NODE ID LAST CONNECT TIME NUMBER OF CONNECTIONS NUMBER OF REJECTIONS AVG CONNECTED TIME");
out.append(lineFeed);
out.append("-------------------------------------------------------------------------------------------------------------------------------");
out.append(lineFeed);
Map<String, NodeConnectionStatistics> nodeStats = stats.get(pool);
for (String nodeId : nodeStats.keySet()) {
NodeConnectionStatistics nodeStat = nodeStats.get(nodeId);
out.append(StringUtils.leftPad(nodeId, 20));
out.append(StringUtils.leftPad(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(nodeStat.getLastConnectionTimeMs())), 30));
out.append(StringUtils.leftPad(Long.toString(nodeStat.getTotalConnectionCount()), 27));
out.append(StringUtils.leftPad(Integer.toString(nodeStat.getNumOfRejections()), 25));
out.append(StringUtils.leftPad(NumberFormat.getIntegerInstance().format(nodeStat.getTotalConnectionTimeMs() / nodeStat.getTotalConnectionCount()), 25));
}
out.append(lineFeed);
}
return out.toString();
}
Aggregations