Search in sources :

Example 6 with QueryMgr

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));
    }
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr) AMXConfig(com.sun.appserv.management.config.AMXConfig) Date(java.util.Date) IOException(java.io.IOException) ObjectName(javax.management.ObjectName) J2EEManagedObject(com.sun.appserv.management.j2ee.J2EEManagedObject) StateManageable(com.sun.appserv.management.j2ee.StateManageable) EventProvider(com.sun.appserv.management.j2ee.EventProvider) Monitoring(com.sun.appserv.management.monitor.Monitoring) HashSet(java.util.HashSet)

Example 7 with QueryMgr

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();
        }
    }
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr) Set(java.util.Set) BeanCacheMonitor(com.sun.appserv.management.monitor.BeanCacheMonitor) Iterator(java.util.Iterator) BoundedRangeStatistic(org.glassfish.j2ee.statistics.BoundedRangeStatistic) CountStatistic(org.glassfish.j2ee.statistics.CountStatistic) EJBCacheStats(com.sun.appserv.management.monitor.statistics.EJBCacheStats)

Example 8 with QueryMgr

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);
        }
    }
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr) NumberStatistic(com.sun.appserv.management.j2ee.statistics.NumberStatistic) Set(java.util.Set) WebServiceEndpointAggregateStats(com.sun.appserv.management.monitor.statistics.WebServiceEndpointAggregateStats) Iterator(java.util.Iterator) WebServiceEndpointMonitor(com.sun.appserv.management.monitor.WebServiceEndpointMonitor) CountStatistic(org.glassfish.j2ee.statistics.CountStatistic)

Example 9 with QueryMgr

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()));
    }
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr) Container(com.sun.appserv.management.base.Container) HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) AMX(com.sun.appserv.management.base.AMX) AttributeNotFoundException(javax.management.AttributeNotFoundException) IOException(java.io.IOException) JMException(javax.management.JMException) ObjectName(javax.management.ObjectName)

Example 10 with QueryMgr

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()));
        }
    }
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr) JVM(com.sun.appserv.management.j2ee.JVM) HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator)

Aggregations

QueryMgr (com.sun.appserv.management.base.QueryMgr)11 Iterator (java.util.Iterator)6 Set (java.util.Set)6 ObjectName (javax.management.ObjectName)5 HashSet (java.util.HashSet)4 AMX (com.sun.appserv.management.base.AMX)2 SSLConfig (com.sun.appserv.management.config.SSLConfig)2 IOException (java.io.IOException)2 CountStatistic (org.glassfish.j2ee.statistics.CountStatistic)2 DomainRoot (com.sun.appserv.management.DomainRoot)1 Container (com.sun.appserv.management.base.Container)1 NotificationService (com.sun.appserv.management.base.NotificationService)1 AMXConfig (com.sun.appserv.management.config.AMXConfig)1 NotificationServiceHelper (com.sun.appserv.management.helper.NotificationServiceHelper)1 EventProvider (com.sun.appserv.management.j2ee.EventProvider)1 J2EEManagedObject (com.sun.appserv.management.j2ee.J2EEManagedObject)1 JVM (com.sun.appserv.management.j2ee.JVM)1 StateManageable (com.sun.appserv.management.j2ee.StateManageable)1 NumberStatistic (com.sun.appserv.management.j2ee.statistics.NumberStatistic)1 BeanCacheMonitor (com.sun.appserv.management.monitor.BeanCacheMonitor)1