Search in sources :

Example 6 with Container

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

the class AMXTest method checkMapsHaveCreateRemove.

/**
 *     Verify that all getAbcConfigMgr() calls return a non-null result.
 */
public void checkMapsHaveCreateRemove(final ObjectName objectName) throws Exception {
    final AMX proxy = getProxyFactory().getProxy(objectName, AMX.class);
    if (proxy instanceof Container && proxy.getGroup().equals(AMX.GROUP_CONFIGURATION)) {
        final Extra extra = Util.getExtra(proxy);
        final String[] attrNames = extra.getAttributeNames();
        for (int i = 0; i < attrNames.length; ++i) {
            final String name = attrNames[i];
            final String SUFFIX = "ObjectNameMap";
            final String PREFIX = JMXUtil.GET;
            if (name.endsWith(SUFFIX)) {
                final String base = StringUtil.stripPrefixAndSuffix(name, PREFIX, SUFFIX);
                if (base.endsWith("ConnectorModuleConfig")) {
                    // these are created via deployment not directly
                    continue;
                }
                final String createName = "create" + base;
                final String removeName = "remove" + base;
                final String j2eeType = proxy.getJ2EEType();
                if (ignoreCreateRemove(proxy.getJ2EEType(), createName)) {
                    continue;
                }
                final MBeanOperationInfo[] creates = JMXUtil.findOperations(extra.getMBeanInfo().getOperations(), createName);
                boolean haveCreate = false;
                for (int op = 0; op < creates.length; ++op) {
                    final MBeanOperationInfo info = creates[op];
                    if (info.getReturnType().equals(ObjectName.class.getName())) {
                        haveCreate = true;
                        break;
                    }
                }
                assert (haveCreate) : "Missing operation " + createName + "() for " + objectName;
                final MBeanOperationInfo[] removes = JMXUtil.findOperations(extra.getMBeanInfo().getOperations(), removeName);
                boolean haveRemove = false;
                for (int op = 0; op < removes.length; ++op) {
                    final MBeanOperationInfo info = removes[op];
                    if (info.getReturnType().equals("void") && info.getSignature().length <= 2) {
                        haveRemove = true;
                        break;
                    }
                }
                assert (haveRemove) : "Missing operation " + removeName + "() for " + objectName;
            }
        }
    }
}
Also used : Container(com.sun.appserv.management.base.Container) Extra(com.sun.appserv.management.base.Extra) MBeanOperationInfo(javax.management.MBeanOperationInfo) AMX(com.sun.appserv.management.base.AMX) ObjectName(javax.management.ObjectName)

Example 7 with Container

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

the class ConfigMgrTestBase method testCreateRemove.

public final synchronized void testCreateRemove() throws Exception {
    if (!checkNotOffline("testCreateRemove")) {
        return;
    }
    final long start = now();
    String name = getProgenyTestName();
    final String progenyJ2EEType = getProgenyJ2EEType();
    AMXConfig proxy = getProgeny(name);
    if (proxy != null) {
        final ObjectName objectName = Util.getExtra(proxy).getObjectName();
        remove(name);
        waitUnregistered(objectName);
        assert (!getConnection().isRegistered(objectName));
        assert (getProgeny(name) == null);
        proxy = null;
    }
    final Container container = getProgenyContainer();
    final CreateRemoveListener listener = new CreateRemoveListener(container, progenyJ2EEType, name);
    // create it
    try {
        proxy = createProgeny(name, null);
    } catch (Exception e) {
        trace(getStackTrace(ExceptionUtil.getRootCause(e)));
        failure("Can't create item of j2eeType=" + progenyJ2EEType + ",name=" + name);
    }
    assert (proxy.getName().equals(name));
    final ObjectName objectName = Util.getObjectName(proxy);
    assert (getConnection().isRegistered(objectName));
    assert (container.getContainee(progenyJ2EEType, name) != null);
    assert (container.getContainee(progenyJ2EEType, name) == proxy);
    final AMXConfig progeny = getProgeny(name);
    assert (progeny == proxy);
    // remove it
    final ProxyFactory factory = Util.getExtra(proxy).getProxyFactory();
    assert (name.equals(progeny.getName()));
    remove(name);
    waitUnregistered(objectName);
    assert (!getConnection().isRegistered(objectName));
    waitProxyGone(factory, objectName);
    assert (getProgeny(name) == null);
    listener.waitNotifs();
    printElapsed("testCreateRemove: created/remove/listen for: " + progenyJ2EEType, start);
}
Also used : Container(com.sun.appserv.management.base.Container) ProxyFactory(com.sun.appserv.management.client.ProxyFactory) AMXConfig(com.sun.appserv.management.config.AMXConfig) CreateRemoveListener(org.glassfish.admin.amxtest.support.CreateRemoveListener) ObjectName(javax.management.ObjectName)

Aggregations

Container (com.sun.appserv.management.base.Container)7 AMX (com.sun.appserv.management.base.AMX)6 ObjectName (javax.management.ObjectName)4 AMXConfig (com.sun.appserv.management.config.AMXConfig)3 Method (java.lang.reflect.Method)2 MBeanInfo (javax.management.MBeanInfo)2 MBeanOperationInfo (javax.management.MBeanOperationInfo)2 DomainRoot (com.sun.appserv.management.DomainRoot)1 Extra (com.sun.appserv.management.base.Extra)1 QueryMgr (com.sun.appserv.management.base.QueryMgr)1 ProxyFactory (com.sun.appserv.management.client.ProxyFactory)1 SecurityMapConfig (com.sun.appserv.management.config.SecurityMapConfig)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 AttributeNotFoundException (javax.management.AttributeNotFoundException)1 JMException (javax.management.JMException)1 MBeanServerConnection (javax.management.MBeanServerConnection)1 CreateRemoveListener (org.glassfish.admin.amxtest.support.CreateRemoveListener)1