Search in sources :

Example 6 with Statistic

use of org.glassfish.j2ee.statistics.Statistic in project Payara by payara.

the class MonitorTest method checkNumStatistics.

public void checkNumStatistics(final MonitoringStats mon) {
    final Stats stats = mon.getStats();
    assert (stats != null) : "null Stats from: " + Util.getObjectName(mon);
    final String[] allNames = mon.getStatisticNames();
    final Statistic[] statistics = mon.getStatistics(allNames);
    assert (statistics.length == allNames.length) : "wrong number of statistics from: " + Util.getObjectName(mon) + ", got " + statistics.length + ", should be " + allNames.length;
}
Also used : CountStatistic(org.glassfish.j2ee.statistics.CountStatistic) BoundaryStatistic(org.glassfish.j2ee.statistics.BoundaryStatistic) Statistic(org.glassfish.j2ee.statistics.Statistic) TimeStatistic(org.glassfish.j2ee.statistics.TimeStatistic) BoundedRangeStatistic(org.glassfish.j2ee.statistics.BoundedRangeStatistic) StringStatistic(com.sun.appserv.management.j2ee.statistics.StringStatistic) RangeStatistic(org.glassfish.j2ee.statistics.RangeStatistic) Stats(org.glassfish.j2ee.statistics.Stats) MonitoringStats(com.sun.appserv.management.monitor.MonitoringStats)

Example 7 with Statistic

use of org.glassfish.j2ee.statistics.Statistic in project Payara by payara.

the class StatisticTest method checkOpenDataConversion.

private void checkOpenDataConversion(final Statistic s) throws OpenDataException {
    final CompositeData d = J2EEUtil.statisticToCompositeData(s);
    final Statistic roundTrip = StatisticFactory.create(d);
    assert (s.equals(roundTrip)) : "Conversion to CompositeData and back to Statistic failed:\n" + toString(s) + " != " + toString(roundTrip);
}
Also used : Statistic(org.glassfish.j2ee.statistics.Statistic) CompositeData(javax.management.openmbean.CompositeData)

Example 8 with Statistic

use of org.glassfish.j2ee.statistics.Statistic in project Payara by payara.

the class StatsImpl method statToString.

public String statToString() {
    StringBuffer sbuf = new StringBuffer();
    Statistic[] stats = getStatistics();
    int sz = stats.length;
    for (int i = 0; i < sz; i++) {
        if (stats[i] instanceof CountStatistic) {
            CountStatistic stat = (CountStatistic) stats[i];
            sbuf.append(stat.getName()).append("=").append(stat.getCount()).append("; ");
        } else if (stats[i] instanceof BoundedRangeStatistic) {
            BoundedRangeStatistic stat = (BoundedRangeStatistic) stats[i];
            sbuf.append(stat.getName()).append("=").append(stat.getCurrent()).append("; ");
        } else {
            sbuf.append(stats[i].getName()).append("=?");
        }
    }
    return sbuf.toString();
}
Also used : BoundedRangeStatistic(org.glassfish.j2ee.statistics.BoundedRangeStatistic) CountStatistic(org.glassfish.j2ee.statistics.CountStatistic) Statistic(org.glassfish.j2ee.statistics.Statistic) CountStatistic(org.glassfish.j2ee.statistics.CountStatistic) BoundedRangeStatistic(org.glassfish.j2ee.statistics.BoundedRangeStatistic)

Aggregations

Statistic (org.glassfish.j2ee.statistics.Statistic)8 BoundedRangeStatistic (org.glassfish.j2ee.statistics.BoundedRangeStatistic)6 CountStatistic (org.glassfish.j2ee.statistics.CountStatistic)6 StringStatistic (com.sun.appserv.management.j2ee.statistics.StringStatistic)5 BoundaryStatistic (org.glassfish.j2ee.statistics.BoundaryStatistic)5 RangeStatistic (org.glassfish.j2ee.statistics.RangeStatistic)5 TimeStatistic (org.glassfish.j2ee.statistics.TimeStatistic)5 MonitoringStats (com.sun.appserv.management.monitor.MonitoringStats)4 Stats (org.glassfish.j2ee.statistics.Stats)4 ObjectName (javax.management.ObjectName)3 CompositeData (javax.management.openmbean.CompositeData)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Iterator (java.util.Iterator)1 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)1