Search in sources :

Example 1 with ManagedAttribute

use of org.springframework.jmx.export.annotation.ManagedAttribute in project symmetric-ds by JumpMind.

the class ParameterManagementService method getParametersList.

@ManagedAttribute(description = "The parameters configured for this SymmetricDS instance")
public String getParametersList() {
    StringBuilder buffer = new StringBuilder();
    TypedProperties properties = parameterService.getAllParameters();
    buffer.append("<pre>");
    for (Object key : properties.keySet()) {
        buffer.append(key).append("=").append(properties.get(key)).append("\n");
    }
    buffer.append("</pre>");
    return buffer.toString();
}
Also used : TypedProperties(org.jumpmind.properties.TypedProperties) ManagedAttribute(org.springframework.jmx.export.annotation.ManagedAttribute)

Example 2 with ManagedAttribute

use of org.springframework.jmx.export.annotation.ManagedAttribute 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

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