Search in sources :

Example 46 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project acs-aem-commons by Adobe-Consulting-Services.

the class AbstractGuavaCacheMBean method getCacheStats.

@Override
@SuppressWarnings("squid:S1192")
public final TabularData getCacheStats() throws OpenDataException {
    // Exposing all google guava stats.
    final CompositeType cacheEntryType = new CompositeType(JMX_PN_CACHESTATS, JMX_PN_CACHESTATS, new String[] { JMX_PN_STAT, JMX_PN_VALUE }, new String[] { JMX_PN_STAT, JMX_PN_VALUE }, new OpenType[] { SimpleType.STRING, SimpleType.STRING });
    final TabularDataSupport tabularData = new TabularDataSupport(new TabularType(JMX_PN_CACHESTATS, JMX_PN_CACHESTATS, cacheEntryType, new String[] { JMX_PN_STAT }));
    CacheStats cacheStats = getCache().stats();
    final Map<String, Object> row = new HashMap<String, Object>();
    row.put(JMX_PN_STAT, "Request Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.requestCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Hit Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.hitCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Hit Rate");
    row.put(JMX_PN_VALUE, String.format("%.0f%%", cacheStats.hitRate() * 100));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Miss Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.missCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Miss Rate");
    row.put(JMX_PN_VALUE, String.format("%.0f%%", cacheStats.missRate() * 100));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Eviction Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.evictionCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Load Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.loadCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Load Exception Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.loadExceptionCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Load Exception Rate");
    row.put(JMX_PN_VALUE, String.format("%.0f%%", cacheStats.loadExceptionRate() * 100));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Load Success Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.loadSuccessCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Average Load Penalty");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.averageLoadPenalty()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    row.put(JMX_PN_STAT, "Total Load Time");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.totalLoadTime()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));
    return tabularData;
}
Also used : HashMap(java.util.HashMap) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CacheStats(com.google.common.cache.CacheStats) CompositeType(javax.management.openmbean.CompositeType)

Example 47 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project openj9 by eclipse.

the class ProcessorUsageUtil method toCompositeData.

/**
 * @param usage a {@link ProcessorUsage} object
 * @return a {@link CompositeData} object that represents the supplied <code>usage</code> object
 */
public static CompositeData toCompositeData(ProcessorUsage usage) {
    CompositeData result = null;
    if (null != usage) {
        CompositeType type = getCompositeType();
        String[] names = { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "user", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "system", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "idle", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "wait", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "busy", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "id", "online", // $NON-NLS-1$ //$NON-NLS-2$
        "timestamp" };
        Object[] values = { Long.valueOf(usage.getUser()), Long.valueOf(usage.getSystem()), Long.valueOf(usage.getIdle()), Long.valueOf(usage.getWait()), Long.valueOf(usage.getBusy()), Integer.valueOf(usage.getId()), Integer.valueOf(usage.getOnline()), Long.valueOf(usage.getTimestamp()) };
        try {
            result = new CompositeDataSupport(type, names, values);
        } catch (OpenDataException e) {
            if (ManagementUtils.VERBOSE_MODE) {
                e.printStackTrace(System.err);
            }
        }
    }
    return result;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 48 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project openj9 by eclipse.

the class GuestOSMemoryUsageUtil method toCompositeData.

/**
 * @param usage a {@link GuestOSMemoryUsage} object
 * @return a {@link CompositeData} object that represents the supplied <code>usage</code> object
 */
public static CompositeData toCompositeData(GuestOSMemoryUsage usage) {
    CompositeData result = null;
    if (null != usage) {
        CompositeType type = getCompositeType();
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        String[] names = { "memUsed", "timestamp", "maxMemLimit" };
        Object[] values = { Long.valueOf(usage.getMemUsed()), Long.valueOf(usage.getTimestamp()), Long.valueOf(usage.getMaxMemLimit()) };
        try {
            result = new CompositeDataSupport(type, names, values);
        } catch (OpenDataException e) {
            if (ManagementUtils.VERBOSE_MODE) {
                e.printStackTrace(System.err);
            }
        }
    }
    return result;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 49 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project openj9 by eclipse.

the class TestMonitorInfo method createGoodStackTraceElementCompositeData.

/**
 * @return new <code>CompositeData</code> representing a
 *         <code>StackTraceElement</code>.
 */
public static CompositeData createGoodStackTraceElementCompositeData() {
    CompositeData result = null;
    CompositeType cType = createStackTraceElementCompositeTypeObject();
    String[] names;
    Object[] values;
    if (TestMisc.isJava9) {
        String[] namesTmp = TestMisc.getJava9STEMethodNames();
        Object[] valuesTmp = { new String("foo.bar.Blobby"), new String("takeOverWorld"), new String("Blobby.java"), new Integer(2100), new Boolean(false), new String("myModuleName"), new String("myModuleVersion"), new String("myClassLoaderName") };
        names = namesTmp;
        values = valuesTmp;
    } else {
        String[] namesTmp = { "className", "methodName", "fileName", "lineNumber", "nativeMethod" };
        Object[] valuesTmp = { new String("foo.bar.Blobby"), new String("takeOverWorld"), new String("Blobby.java"), new Integer(2100), new Boolean(false) };
        names = namesTmp;
        values = valuesTmp;
    }
    try {
        result = new CompositeDataSupport(cType, names, values);
    } catch (OpenDataException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return result;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 50 with CompositeDataSupport

use of javax.management.openmbean.CompositeDataSupport in project openj9 by eclipse.

the class TestMonitorInfo method createGoodCompositeData.

/**
 * @return a new <code>CompositeData</code> instance representing a
 *         <code>MonitorInfo</code>.
 */
static CompositeData createGoodCompositeData() {
    CompositeData result = null;
    String[] names = { "className", "identityHashCode", "lockedStackFrame", "lockedStackDepth" };
    Object[] values = { /* className */
    new String(GOOD_CD_CLASSNAME), /* identityHashCode */
    new Integer(GOOD_CD_IDHASHCODE), /* lockedStackFrame */
    createGoodStackTraceElementCompositeData(), /* lockedStackDepth */
    new Integer(GOOD_CD_STACKDEPTH) };
    CompositeType cType = createGoodMonitorInfoCompositeType();
    try {
        result = new CompositeDataSupport(cType, names, values);
    } catch (OpenDataException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return result;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Aggregations

CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)166 CompositeData (javax.management.openmbean.CompositeData)107 CompositeType (javax.management.openmbean.CompositeType)105 TabularDataSupport (javax.management.openmbean.TabularDataSupport)78 OpenDataException (javax.management.openmbean.OpenDataException)66 TabularData (javax.management.openmbean.TabularData)46 HashMap (java.util.HashMap)36 TabularType (javax.management.openmbean.TabularType)30 Map (java.util.Map)26 OpenType (javax.management.openmbean.OpenType)15 ObjectName (javax.management.ObjectName)12 MBeanServer (javax.management.MBeanServer)8 Test (org.junit.Test)8 IOException (java.io.IOException)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 MBeanException (javax.management.MBeanException)6 JsonArray (javax.json.JsonArray)5 JsonObject (javax.json.JsonObject)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4