Search in sources :

Example 1 with AMXDebugStuff

use of org.glassfish.admin.amx.util.AMXDebugStuff 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 2 with AMXDebugStuff

use of org.glassfish.admin.amx.util.AMXDebugStuff 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 3 with AMXDebugStuff

use of org.glassfish.admin.amx.util.AMXDebugStuff in project Payara by payara.

the class TestUtil method asAMXDebugStuff.

public AMXDebugStuff asAMXDebugStuff(final AMX amx) {
    final String[] attrNames = Util.getExtra(amx).getAttributeNames();
    AMXDebugStuff result = null;
    if (GSetUtil.newUnmodifiableStringSet(attrNames).contains("AMXDebug")) {
        final ProxyFactory factory = Util.getExtra(amx).getProxyFactory();
        try {
            final Class amxClass = ClassUtil.getClassFromName(Util.getExtra(amx).getInterfaceName());
            final Class[] interfaces = new Class[] { amxClass, AMXDebugStuff.class };
            final ObjectName objectName = Util.getObjectName(amx);
            return (AMXDebugStuff) factory.newProxyInstance(objectName, interfaces);
        } catch (Exception e) {
            trace(ExceptionUtil.toString(e));
            throw new RuntimeException(e);
        }
    }
    return result;
}
Also used : ProxyFactory(com.sun.appserv.management.client.ProxyFactory) AMXDebugStuff(org.glassfish.admin.amx.util.AMXDebugStuff) ObjectName(javax.management.ObjectName)

Example 4 with AMXDebugStuff

use of org.glassfish.admin.amx.util.AMXDebugStuff in project Payara by payara.

the class AMXTest method testToString.

public void testToString() {
    final long start = now();
    final Set<AMX> all = getAllAMX();
    for (final AMX amx : all) {
        final AMXDebugStuff debug = getTestUtil().asAMXDebugStuff(amx);
        if (debug != null) {
            final String s = debug.getImplString(true);
            assert (s.length() != 0);
        }
    }
    printElapsed("testToString", all.size(), start);
}
Also used : AMXDebugStuff(org.glassfish.admin.amx.util.AMXDebugStuff) AMX(com.sun.appserv.management.base.AMX)

Aggregations

AMXDebugStuff (org.glassfish.admin.amx.util.AMXDebugStuff)4 AMX (com.sun.appserv.management.base.AMX)3 AMXDebugSupportMBean (com.sun.appserv.management.base.AMXDebugSupportMBean)1 ProxyFactory (com.sun.appserv.management.client.ProxyFactory)1 ConfigConfig (com.sun.appserv.management.config.ConfigConfig)1 JavaConfig (com.sun.appserv.management.config.JavaConfig)1 CoverageInfo (com.sun.appserv.management.ext.coverage.CoverageInfo)1 HashMap (java.util.HashMap)1 ObjectName (javax.management.ObjectName)1