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