Search in sources :

Example 1 with QueryMgr

use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.

the class NotificationServiceTest method testListen.

public void testListen() throws Exception {
    // trace( "testListen: START" );
    final NotificationService proxy = create();
    final QueryMgr queryMgr = getQueryMgr();
    final ObjectName objectName = Util.getObjectName(queryMgr);
    final Object id = proxy.createBuffer(10, null);
    final NotificationServiceHelper helper = new NotificationServiceHelper(proxy, id);
    proxy.listenTo(objectName, null);
    assert (proxy.getListeneeSet().size() == 1);
    assert (Util.getObjectName((Util.asAMX(proxy.getListeneeSet().iterator().next()))).equals(objectName));
    // trace( "testListen: NEWING" );
    // we expect two changes, see below
    final MyListener myListener = new MyListener(2);
    proxy.addNotificationListener(myListener, null, null);
    final String saveLevel = queryMgr.getMBeanLogLevel();
    queryMgr.setMBeanLogLevel("" + Level.FINEST);
    queryMgr.setMBeanLogLevel(saveLevel);
    // delivery may be asynchronous; wait until done
    if (!myListener.await(5, TimeUnit.SECONDS)) {
        // trace( "testListen: FAILED TIMEOUT" );
        assert false : "NotificationServiceTest.testListen():  TIMED OUT waiting for Notifications";
    }
    // trace( "testListen: NOT FAILED" );
    assert (myListener.getCount() == 2);
    Notification[] notifs = helper.getNotifications();
    assertEquals(2, notifs.length);
    assert (notifs[0].getType().equals(AttributeChangeNotification.ATTRIBUTE_CHANGE));
    assert (notifs[1].getType().equals(AttributeChangeNotification.ATTRIBUTE_CHANGE));
    notifs = helper.getNotifications();
    assert (notifs.length == 0);
    proxy.dontListenTo(objectName);
    assert (proxy.getListeneeSet().size() == 0);
    removeNotificationService(proxy);
// trace( "testListen: EXIT" );
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr) NotificationServiceHelper(com.sun.appserv.management.helper.NotificationServiceHelper) NotificationService(com.sun.appserv.management.base.NotificationService) Notification(javax.management.Notification) AttributeChangeNotification(javax.management.AttributeChangeNotification) ObjectName(javax.management.ObjectName)

Example 2 with QueryMgr

use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.

the class QueryMgrTest method testQueryInterfaceObjectNames.

/**
 *     Final all available interfaces, then for each type of interface, query
 *     for all items that have the interface and verify that's the interface
 *     they return from getInterfaceName().
 */
public void testQueryInterfaceObjectNames() throws Exception {
    final long start = now();
    final QueryMgr queryMgr = getQueryMgr();
    final Set<AMX> allAMX = getQueryMgr().queryAllSet();
    final Set<ObjectName> allAMXObjectNames = Util.toObjectNames(allAMX);
    final Set<String> interfaceNames = getAllInterfaceNames(allAMX);
    for (final String interfaceName : interfaceNames) {
        final Set amxs = queryMgr.queryInterfaceSet(interfaceName, allAMXObjectNames);
        final Iterator amxIter = amxs.iterator();
        while (amxIter.hasNext()) {
            final AMX amx = Util.asAMX(amxIter.next());
            assert (interfaceName.equals(Util.getExtra(amx).getInterfaceName()));
        }
    }
    printElapsed("testQueryInterfaceObjectNames", start);
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr) Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) AMX(com.sun.appserv.management.base.AMX) ObjectName(javax.management.ObjectName)

Example 3 with QueryMgr

use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.

the class PerformanceTest method xtestQueryMgr.

public synchronized void xtestQueryMgr() throws IllegalAccessException, InvocationTargetException {
    final DomainRoot domainRoot = getDomainRoot();
    final QueryMgr queryMgr = domainRoot.getQueryMgr();
    final String domain = Util.getObjectName(queryMgr).getDomain();
    printPerf("-- QueryMgr --- ");
    testMethod(domainRoot, "getQueryMgr", null, 1000);
    final int ITER = 20;
    testMethod(queryMgr, "queryAllSet", null, ITER);
    testMethod(queryMgr, "querySingletonJ2EEType", new Object[] { XTypes.BULK_ACCESS }, ITER);
    testMethod(queryMgr, "queryJ2EETypeSet", new Object[] { XTypes.SSL_CONFIG }, ITER);
    testMethod(queryMgr, "queryJ2EENameSet", new Object[] { "server" }, ITER);
    testMethod(queryMgr, "queryJ2EETypeNames", new Object[] { XTypes.CONFIG_CONFIG }, ITER);
    testMethod(queryMgr, "queryPatternSet", new Object[] { domain, "j2eeType=" + XTypes.SERVLET_MONITOR }, ITER);
    testMethod(queryMgr, "queryInterfaceSet", new Object[] { SSLConfig.class.getName(), null }, ITER);
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr) SSLConfig(com.sun.appserv.management.config.SSLConfig) DomainRoot(com.sun.appserv.management.DomainRoot)

Example 4 with QueryMgr

use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.

the class ProxyTest method testQueryMgr.

public void testQueryMgr() throws Exception {
    final QueryMgr proxy = (QueryMgr) getQueryMgr();
    Util.getObjectName(proxy);
    proxy.getContainer();
    proxy.getDomainRoot();
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr)

Example 5 with QueryMgr

use of com.sun.appserv.management.base.QueryMgr in project Payara by payara.

the class SSLConfigTest method testGetAttrs.

public void testGetAttrs() {
    final QueryMgr queryMgr = getQueryMgr();
    final String props = Util.makeJ2EETypeProp(XTypes.SSL_CONFIG);
    final Set sslConfigs = queryMgr.queryPropsSet(props);
    final Iterator iter = sslConfigs.iterator();
    while (iter.hasNext()) {
        final SSLConfig ssl = (SSLConfig) iter.next();
        ssl.getCertNickname();
        ssl.getClientAuthEnabled();
        ssl.getSSL2Enabled();
        ssl.getSSL2Ciphers();
        ssl.getSSL3Enabled();
        ssl.getSSL3TLSCiphers();
        ssl.getTLSEnabled();
        ssl.getTLSRollbackEnabled();
    }
}
Also used : QueryMgr(com.sun.appserv.management.base.QueryMgr) SSLConfig(com.sun.appserv.management.config.SSLConfig) 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