use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.
the class J2EETest method testJ2EE.
public void testJ2EE() throws ClassNotFoundException {
final QueryMgr queryMgr = getQueryMgr();
final Set<J2EEManagedObject> j2eeAll = queryMgr.queryInterfaceSet(J2EEManagedObject.class.getName(), null);
final Set<ObjectName> failedSet = new HashSet<ObjectName>();
final Set<ObjectName> noPeerSet = new HashSet<ObjectName>();
for (final J2EEManagedObject item : j2eeAll) {
final ObjectName objectName = Util.getObjectName(item);
assert (objectName.equals(Util.newObjectName(item.getobjectName())));
final String j2eeType = item.getJ2EEType();
if (item.isstateManageable()) {
assert (item instanceof StateManageable);
final StateManageable sm = (StateManageable) item;
final int state = sm.getstate();
assert (state == StateManageable.STATE_STARTING || state == StateManageable.STATE_RUNNING || state == StateManageable.STATE_STOPPING || state == StateManageable.STATE_STOPPED || state == StateManageable.STATE_FAILED);
if (state == StateManageable.STATE_RUNNING) {
try {
final long startTime = sm.getstartTime();
// assume it was started less than 30 days ago
final long MILLIS_PER_DAY = 24L * 60L * 60L * 1000L;
final long days30 = 30L * MILLIS_PER_DAY;
if (startTime < now() - days30) {
warning("MBean " + quote(objectName) + " claims a start time of " + new Date(startTime) + ", which is more than 30 days prior to now = " + new Date(now()));
failedSet.add(objectName);
}
} catch (Exception e) {
final Throwable rootCause = ExceptionUtil.getRootCause(e);
warning("MBean " + quote(objectName) + " is 'stateManageable' and in 'STATE_RUNNING', but could not supply Attribute 'startTime', " + "threw an exception of class " + rootCause.getClass().getName());
failedSet.add(objectName);
}
}
}
if (item.iseventProvider()) {
assert (item instanceof EventProvider);
final EventProvider ep = (EventProvider) item;
final String[] types = ep.gettypes();
assert types != null : "Item claims to be EventProvider, but provides null 'types': " + toString(objectName);
}
/*
monitoring was enabled so monitoring peers should exist
Can't just call isStatisticProvider(), since it will be false
if the monitoring peer is null (correctly or incorrectly).
*/
final String monitoringPeerJ2EEType = getMonitoringPeerJ2EEType(j2eeType);
final Monitoring monitoringPeer = item.getMonitoringPeer();
if (monitoringPeerJ2EEType != null) {
// See if there actually is a monitoring peer, but null is being returned.
if (monitoringPeer == null) {
final String props = getMonitoringPeerProps(item);
final Set<Monitoring> monitors = getQueryMgr().queryPropsSet(props);
if (monitors.size() != 0) {
warning("MBean " + quote(objectName) + " returned null for its monitoring peer, but found the following:" + NEWLINE + CollectionUtil.toString(Util.toObjectNames(monitors), NEWLINE));
failedSet.add(objectName);
}
} else {
// statistics
if (!HasNoStats.contains(j2eeType)) {
assert item.isstatisticProvider() && item.isstatisticsProvider();
}
}
} else {
// it has a monitoring peer
if (item.isstatisticProvider() || item.isstatisticsProvider()) {
warning("MBean " + quote(objectName) + " should not have its statisticProvider set to true");
failedSet.add(objectName);
}
}
if (item.isConfigProvider()) {
final AMXConfig config = item.getConfigPeer();
if (config == null) {
// Some auto-generated items do not have config. See if it's there
final String props = Util.makeRequiredProps(getConfigPeerJ2EEType(j2eeType), item.getName());
if (getQueryMgr().queryPropsSet(props).size() != 0) {
warning("MBean " + quote(objectName) + " has existing config peer, but returned null");
failedSet.add(objectName);
}
}
}
}
if (noPeerSet.size() != 0) {
warning("The following MBeans do not have a Monitoring peer:" + NEWLINE + toString(noPeerSet));
}
if (failedSet.size() != 0) {
failure("Failures in the following " + failedSet.size() + " MBeans:\n" + toString(failedSet));
}
}
use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.
the class BeanCacheMonitorTest method testStats.
public void testStats() {
final QueryMgr q = getQueryMgr();
final Set beanCacheMonitors = q.queryJ2EETypeSet(XTypes.BEAN_CACHE_MONITOR);
if (beanCacheMonitors.size() == 0) {
warning("BeanCacheMonitorTest: no MBeans found to test.");
} else {
final Iterator iter = beanCacheMonitors.iterator();
while (iter.hasNext()) {
final BeanCacheMonitor m = (BeanCacheMonitor) iter.next();
final EJBCacheStats s = m.getEJBCacheStats();
// verify that we can get each Statistic; there was a problem at one time
final BoundedRangeStatistic b1 = s.getCacheMisses();
final BoundedRangeStatistic b2 = s.getCacheHits();
final BoundedRangeStatistic b3 = s.getBeansInCache();
// these were failing
final CountStatistic c4 = s.getPassivationSuccesses();
final CountStatistic c3 = s.getExpiredSessionsRemoved();
final CountStatistic c2 = s.getPassivationErrors();
final CountStatistic c1 = s.getPassivations();
}
}
}
use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.
the class WebServiceEndpointMonitorTest method testStats.
public void testStats() {
final QueryMgr q = getQueryMgr();
final Set wsMonitors = q.queryJ2EETypeSet(XTypes.WEBSERVICE_ENDPOINT_MONITOR);
if (wsMonitors.size() == 0) {
warning("WebServiceEndpointMonitorTest: no MBeans found to test.");
} else {
Iterator itr = wsMonitors.iterator();
while (itr.hasNext()) {
WebServiceEndpointMonitor m = (WebServiceEndpointMonitor) itr.next();
final WebServiceEndpointAggregateStats s = m.getWebServiceEndpointAggregateStats();
// verify that we can get each Statistic;
// there was a problem at one time
final CountStatistic r1 = s.getTotalFaults();
assert (r1 != null);
final CountStatistic r2 = s.getTotalNumSuccess();
assert (r2 != null);
// final AverageRangeStatistic r3 = s.getResponseTime();
// assert( r3 != null );
final NumberStatistic c1 = s.getThroughput();
assert (c1 != null);
final CountStatistic c2 = s.getTotalAuthFailures();
assert (c2 != null);
final CountStatistic c3 = s.getTotalAuthSuccesses();
assert (c3 != null);
}
}
}
use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.
the class AMXTest method checkContainerChild.
/**
* Verify that each child's Container actually claims the child as a child.
*/
public void checkContainerChild(final String childJ2EEType) {
final QueryMgr queryMgr = getQueryMgr();
final Set children = queryMgr.queryJ2EETypeSet(childJ2EEType);
final Iterator iter = children.iterator();
while (iter.hasNext()) {
final AMX containee = Util.asAMX(iter.next());
Container container = null;
final ObjectName objectName = Util.getObjectName(containee);
if (!shouldTest(objectName)) {
continue;
}
try {
container = (Container) containee.getContainer();
} catch (Exception e) {
trace("Can't get container for: " + objectName);
}
if (container == null) {
assert (containee.getJ2EEType().equals(XTypes.DOMAIN_ROOT)) : "container is null for: " + objectName;
continue;
}
final Set<AMX> containeeSet = container.getContaineeSet(childJ2EEType);
final Set<ObjectName> containeeObjectNameSet = Util.toObjectNames(containeeSet);
assert (containeeObjectNameSet.contains(Util.getExtra(containee).getObjectName()));
}
}
use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.
the class J2EETest method testJVMs.
public void testJVMs() {
final QueryMgr queryMgr = getQueryMgr();
final Set jvms = queryMgr.queryJ2EETypeSet(J2EETypes.JVM);
final Iterator iter = jvms.iterator();
String lastVendor = null;
String lastVersion = null;
while (iter.hasNext()) {
final JVM jvm = (JVM) iter.next();
// the ObjectName of the Node must match the String version for "node"
assert (jvm.getnode() != null);
// the JVMs should all have the same vendor (presumably)
assert (jvm.getjavaVendor() != null);
if (lastVendor == null) {
lastVendor = jvm.getjavaVendor();
} else {
assert (lastVendor.equals(jvm.getjavaVendor()));
}
// the JVMs should all have the same version (presumably)
assert (jvm.getjavaVersion() != null);
if (lastVersion == null) {
lastVersion = jvm.getjavaVersion();
} else {
assert (lastVersion.equals(jvm.getjavaVersion()));
}
}
}
Aggregations