Search in sources :

Example 1 with TimeWindowStatistics

use of org.glassfish.jersey.server.monitoring.TimeWindowStatistics in project jersey by jersey.

the class ExecutionStatisticsDynamicBean method initMBeanInfo.

private MBeanInfo initMBeanInfo(final ExecutionStatistics initialStatistics) {
    final Map<Long, TimeWindowStatistics> statsMap = initialStatistics.getTimeWindowStatistics();
    MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[statsMap.size() * 5];
    int i = 0;
    for (final TimeWindowStatistics stats : statsMap.values()) {
        final long interval = stats.getTimeWindow();
        final String postfix = convertIntervalToString((int) interval);
        String name = "MinTime[ms]_" + postfix;
        attrs[i++] = new MBeanAttributeInfo(name, "long", "Minimum request processing time in milliseconds in last " + postfix + ".", true, false, false);
        attributeValues.put(name, new Value<Object>() {

            @Override
            public Object get() {
                return executionStatistics.getTimeWindowStatistics().get(interval).getMinimumDuration();
            }
        });
        name = "MaxTime[ms]_" + postfix;
        attrs[i++] = new MBeanAttributeInfo(name, "long", "Minimum request processing time  in milliseconds in last " + postfix + ".", true, false, false);
        attributeValues.put(name, new Value<Object>() {

            @Override
            public Object get() {
                return executionStatistics.getTimeWindowStatistics().get(interval).getMaximumDuration();
            }
        });
        name = "AverageTime[ms]_" + postfix;
        attrs[i++] = new MBeanAttributeInfo(name, "long", "Average request processing time in milliseconds in last " + postfix + ".", true, false, false);
        attributeValues.put(name, new Value<Object>() {

            @Override
            public Object get() {
                return executionStatistics.getTimeWindowStatistics().get(interval).getAverageDuration();
            }
        });
        name = "RequestRate[requestsPerSeconds]_" + postfix;
        attrs[i++] = new MBeanAttributeInfo(name, "double", "Average requests per second in last " + postfix + ".", true, false, false);
        attributeValues.put(name, new Value<Object>() {

            @Override
            public Object get() {
                return executionStatistics.getTimeWindowStatistics().get(interval).getRequestsPerSecond();
            }
        });
        name = "RequestCount_" + postfix;
        attrs[i++] = new MBeanAttributeInfo(name, "double", "Request count in last " + postfix + ".", true, false, false);
        attributeValues.put(name, new Value<Object>() {

            @Override
            public Object get() {
                return executionStatistics.getTimeWindowStatistics().get(interval).getRequestCount();
            }
        });
    }
    return new MBeanInfo(this.getClass().getName(), "Execution statistics", attrs, null, null, null);
}
Also used : MBeanInfo(javax.management.MBeanInfo) TimeWindowStatistics(org.glassfish.jersey.server.monitoring.TimeWindowStatistics) MBeanAttributeInfo(javax.management.MBeanAttributeInfo)

Aggregations

MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 MBeanInfo (javax.management.MBeanInfo)1 TimeWindowStatistics (org.glassfish.jersey.server.monitoring.TimeWindowStatistics)1