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);
}
Aggregations