Search in sources :

Example 1 with NodeConnectionStatistics

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();
}
Also used : NodeConnectionStatistics(org.jumpmind.symmetric.transport.ConcurrentConnectionManager.NodeConnectionStatistics) Map(java.util.Map) Date(java.util.Date) ManagedAttribute(org.springframework.jmx.export.annotation.ManagedAttribute)

Aggregations

Date (java.util.Date)1 Map (java.util.Map)1 NodeConnectionStatistics (org.jumpmind.symmetric.transport.ConcurrentConnectionManager.NodeConnectionStatistics)1 ManagedAttribute (org.springframework.jmx.export.annotation.ManagedAttribute)1