Search in sources :

Example 1 with Statistic

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

the class GenericStatsImpl method getStatisticsOneByOne.

private Statistic[] getStatisticsOneByOne() {
    final Iterator iter = getters.keySet().iterator();
    final Statistic[] stats = new Statistic[getters.keySet().size()];
    int i = 0;
    while (iter.hasNext()) {
        final String sn = (String) iter.next();
        stats[i++] = this.getStatistic(sn);
    }
    assert (stats.length == i);
    return (stats);
}
Also used : Statistic(org.glassfish.j2ee.statistics.Statistic) Iterator(java.util.Iterator)

Example 2 with Statistic

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

the class MonitorTest method checkGetStatistic.

public void checkGetStatistic(final MonitoringStats mon) {
    final Stats stats = mon.getStats();
    final ObjectName objectName = Util.getObjectName(mon);
    final String[] names = mon.getStatisticNames();
    for (int i = 0; i < names.length; ++i) {
        final String name = names[i];
        final Statistic s = mon.getStatistic(name);
        assert (s != null);
        assert (s.getName().equals(name));
        checkLegalStatistic(objectName, s);
    }
}
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) ObjectName(javax.management.ObjectName)

Example 3 with Statistic

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

the class MonitorTest method checkGetStats.

public void checkGetStats(final MonitoringStats mon) {
    final Stats stats = mon.getStats();
    final ObjectName objectName = Util.getObjectName(mon);
    final String[] names = stats.getStatisticNames();
    for (int i = 0; i < names.length; ++i) {
        final Statistic s = stats.getStatistic(names[i]);
        assert (s != null);
        assert (s.getName().equals(names[i]));
        checkLegalStatistic(objectName, s);
    }
}
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) ObjectName(javax.management.ObjectName)

Example 4 with Statistic

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

the class MonitorTest method checkStats.

public void checkStats(final MonitoringStats mon, final Stats stats) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
    final ObjectName objectName = Util.getObjectName(mon);
    trace("checkStats: " + objectName);
    final Method[] methodsViaNames = J2EEUtil.getStatisticGetterMethodsUsingNames(stats);
    final Method[] methods = stats.getClass().getMethods();
    final Set<String> statisticNames = GSetUtil.newSet(stats.getStatisticNames());
    for (int methodIdx = 0; methodIdx < methodsViaNames.length; ++methodIdx) {
        final Method method = methodsViaNames[methodIdx];
        final String methodName = method.getName();
        final Class<?> returnType = method.getReturnType();
        final String statisticName = getterToName(methodName);
        if (!statisticNames.contains(statisticName)) {
            warning("Statistic " + quote(statisticName) + " as derived from " + method + " missing from " + quote(objectName) + " available names = " + toString(statisticNames));
        }
        try {
            final Object o = method.invoke(stats, (Object[]) null);
            assert (o != null);
            assert (Statistic.class.isAssignableFrom(o.getClass()));
            assert (returnType.isAssignableFrom(o.getClass())) : "Method " + methodName + " of MBean " + objectName + " returned object not assignable to " + returnType.getName();
            final Statistic stat = (Statistic) method.invoke(stats, (Object[]) null);
            assert (method.getReturnType().isAssignableFrom(stat.getClass()));
            final Statistic s = mon.getStatistic(stat.getName());
            assert (returnType.isAssignableFrom(s.getClass())) : "getStatistic() of MBean " + objectName + " returned Statistic not assignable to " + returnType.getName();
        // printVerbose( "Verified " + stat.getClass().getName()  + " " + stat.getName() );
        } catch (Exception e) {
            final Throwable rootCause = ExceptionUtil.getRootCause(e);
            warning("Failure calling " + method + " on Stats for " + objectName + " = " + rootCause.getClass().getName() + "\n" + "Statistic names = " + toString(stats.getStatisticNames()));
        }
    }
}
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) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) ObjectName(javax.management.ObjectName)

Example 5 with Statistic

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

the class MonitorTest method checkGetOpenStatistic.

public void checkGetOpenStatistic(final MonitoringStats mon) {
    final Stats stats = mon.getStats();
    final String[] names = mon.getStatisticNames();
    for (int i = 0; i < names.length; ++i) {
        final String name = names[i];
        final CompositeData d = mon.getOpenStatistic(name);
        final Statistic s = StatisticFactory.create(d);
        final Statistic s2 = mon.getStatistic(name);
        assert (s.getName().equals(name));
    // values may have changed, but check the static fields
    }
    final CompositeDataSupport[] all = mon.getOpenStatistics(names);
    assert (all != null);
    assert (all.length == names.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) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Stats(org.glassfish.j2ee.statistics.Stats) MonitoringStats(com.sun.appserv.management.monitor.MonitoringStats)

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