Search in sources :

Example 11 with AMX

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

the class AMXTestBase method getProxy.

protected final AMX getProxy(final ObjectName objectName) {
    final ProxyFactory factory = ProxyFactory.getInstance(getConnectionSource(), true);
    final AMX proxy = factory.getProxy(objectName, AMX.class);
    return (proxy);
}
Also used : ProxyFactory(com.sun.appserv.management.client.ProxyFactory) AMX(com.sun.appserv.management.base.AMX)

Example 12 with AMX

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

the class CoverageInfoAnalyzer method getCoverage.

public Map<String, CoverageInfo> getCoverage(final Set<AMX> candidates) {
    final Map<String, CoverageInfo> coverageMap = new HashMap<String, CoverageInfo>();
    for (final AMX amx : candidates) {
        final AMXDebugStuff debug = mTestUtil.asAMXDebugStuff(amx);
        final CoverageInfo coverageInfo = debug.getCoverageInfo();
        assert (coverageInfo != null);
        handleSpecialCases(coverageInfo);
        final String j2eeType = amx.getJ2EEType();
        final CoverageInfo existing = coverageMap.get(j2eeType);
        if (existing != null) {
            existing.merge(coverageInfo);
        } else {
            coverageMap.put(j2eeType, coverageInfo);
        }
    }
    return coverageMap;
}
Also used : HashMap(java.util.HashMap) AMXDebugStuff(org.glassfish.admin.amx.util.AMXDebugStuff) AMX(com.sun.appserv.management.base.AMX) CoverageInfo(com.sun.appserv.management.ext.coverage.CoverageInfo)

Example 13 with AMX

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

the class RunMeFirstTest method initCoverageInfos.

private void initCoverageInfos() {
    final Set<AMX> all = getAllAMX();
    // set the AMX-DEBUG flags on
    final String AMX_DEBUG = "-DAMX-DEBUG.enabled=true";
    final String AMX_DEBUG2 = "-DAMX-DEBUG=true";
    // set AMX-DEBUG.enabled=true in all ConfigConfig JVM options
    final Map<String, ConfigConfig> configs = getDomainConfig().getConfigsConfig().getConfigConfigMap();
    for (final ConfigConfig config : configs.values()) {
        final JavaConfig jc = config.getJavaConfig();
        final String[] opt = jc.getJVMOptions();
        final Set<String> jvmOptions = GSetUtil.newStringSet(opt == null ? new String[0] : opt);
        if (!(jvmOptions.contains(AMX_DEBUG) || jvmOptions.contains(AMX_DEBUG2))) {
            jvmOptions.add(AMX_DEBUG);
            jc.setJVMOptions(GSetUtil.toStringArray(jvmOptions));
            // don't warn for default-config; it's not used by a running server
            if (!config.getName().equals("default-config")) {
                warning("Enabled AMX-DEBUG for config " + config.getName() + " (restart required)");
            }
        }
    }
    // setup default stuff
    final AMXDebugSupportMBean debug = getAMXDebugSupportMBean();
    debug.setAll(true);
    debug.setDefaultDebug(true);
    debug.getOutputIDs();
    for (final AMX amx : all) {
        final AMXDebugStuff debugStuff = getTestUtil().asAMXDebugStuff(amx);
        if (debugStuff == null) {
            continue;
        }
        try {
            debugStuff.enableAMXDebug(true);
        } catch (Throwable t) {
            warning("Couldn't enableAMXDebug() for " + amx.getJ2EEType());
        }
        try {
            debugStuff.enableCoverageInfo(true);
            debugStuff.clearCoverageInfo();
        } catch (Throwable t) {
            warning("Couldn't enableCoverageInfo for " + amx.getJ2EEType());
        }
    }
}
Also used : JavaConfig(com.sun.appserv.management.config.JavaConfig) AMXDebugSupportMBean(com.sun.appserv.management.base.AMXDebugSupportMBean) AMXDebugStuff(org.glassfish.admin.amx.util.AMXDebugStuff) ConfigConfig(com.sun.appserv.management.config.ConfigConfig) AMX(com.sun.appserv.management.base.AMX)

Example 14 with AMX

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

the class AMXTest method testInterfaceAgainstDelegate.

public void testInterfaceAgainstDelegate() throws Exception {
    final long start = now();
    final Set<AMX> all = getAllAMX();
    final MBeanServerConnection conn = getMBeanServerConnection();
    for (final AMX amx : all) {
        final String result = (String) conn.invoke(Util.getObjectName(amx), "checkInterfaceAgainstDelegate", null, null);
    }
    printElapsed("testInterfaceAgainstDelegate", all.size(), start);
}
Also used : AMX(com.sun.appserv.management.base.AMX) MBeanServerConnection(javax.management.MBeanServerConnection)

Example 15 with AMX

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

the class AMXTest method checkMaps.

/**
 *     Verify that a proxy getAbcMap(...) Attribute or operation has an appropriate
 *     MBean getAbcObjectNameMap() method.
 */
public void checkMaps(final ObjectName objectName) throws Exception {
    final AMX proxy = getProxyFactory().getProxy(objectName, AMX.class);
    if (proxy instanceof Container) {
        final Method[] methods = getInterfaceClass(proxy).getMethods();
        final MBeanInfo mbeanInfo = Util.getExtra(proxy).getMBeanInfo();
        for (int methodIdx = 0; methodIdx < methods.length; ++methodIdx) {
            final Method method = methods[methodIdx];
            final String methodName = method.getName();
            if (isMapGetter(method)) {
                if (methodName.endsWith(OBJECTNAME_MAP_SUFFIX)) {
                    warning("method should exist in MBeanInfo, not interface: " + methodName);
                    continue;
                }
                // verify that a corresponding peer method exists and
                // has the right return type and same number and type of parameters
                final String peerMethodName = StringUtil.replaceSuffix(methodName, MAP_SUFFIX, OBJECTNAME_MAP_SUFFIX);
                checkCompatibleOperationExists(Util.getObjectName(proxy), method, peerMethodName, mbeanInfo);
            } else if (isMapGetterName(methodName)) {
                warning("operation " + methodName + " does not return a Map!");
            }
        }
    }
}
Also used : Container(com.sun.appserv.management.base.Container) MBeanInfo(javax.management.MBeanInfo) Method(java.lang.reflect.Method) AMX(com.sun.appserv.management.base.AMX)

Aggregations

AMX (com.sun.appserv.management.base.AMX)37 ObjectName (javax.management.ObjectName)10 Container (com.sun.appserv.management.base.Container)6 MBeanInfo (javax.management.MBeanInfo)6 HashSet (java.util.HashSet)5 AMXConfig (com.sun.appserv.management.config.AMXConfig)4 Method (java.lang.reflect.Method)3 Iterator (java.util.Iterator)3 Set (java.util.Set)3 MBeanOperationInfo (javax.management.MBeanOperationInfo)3 MBeanServerConnection (javax.management.MBeanServerConnection)3 AMXDebugStuff (org.glassfish.admin.amx.util.AMXDebugStuff)3 QueryMgr (com.sun.appserv.management.base.QueryMgr)2 ProxyFactory (com.sun.appserv.management.client.ProxyFactory)2 DomainConfig (com.sun.appserv.management.config.DomainConfig)2 CoverageInfo (com.sun.appserv.management.ext.coverage.CoverageInfo)2 Map (java.util.Map)2 TreeSet (java.util.TreeSet)2 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)2 DomainRoot (com.sun.appserv.management.DomainRoot)1