Search in sources :

Example 51 with CompositeDataSupport

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

the class MemoryNotificationInfoUtil method toCompositeData.

/**
 * @param info a {@link java.lang.management.MemoryNotificationInfo} object
 * @return a {@link CompositeData} object that represents the supplied <code>info</code> object
 */
public static CompositeData toCompositeData(MemoryNotificationInfo info) {
    CompositeData result = null;
    if (info != null) {
        CompositeType type = getCompositeType();
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        String[] names = { "poolName", "usage", "count" };
        Object[] values = { info.getPoolName(), MemoryUsageUtil.toCompositeData(info.getUsage()), Long.valueOf(info.getCount()) };
        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 52 with CompositeDataSupport

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

the class MemoryUsageUtil method toCompositeData.

/**
 * @param usage a {@link MemoryUsage} object
 * @return a {@link CompositeData} object that represents the supplied <code>usage</code> object
 */
public static CompositeData toCompositeData(MemoryUsage usage) {
    CompositeData result = null;
    if (usage != null) {
        CompositeType type = getCompositeType();
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        String[] names = { "init", "used", "committed", "max" };
        Object[] values = { Long.valueOf(usage.getInit()), Long.valueOf(usage.getUsed()), Long.valueOf(usage.getCommitted()), Long.valueOf(usage.getMax()) };
        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 53 with CompositeDataSupport

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

the class MemoryUsageUtil method toTabularData.

/**
 * @param map a set of named {@link MemoryUsage} objects
 * @return a {@link TabularData} object that represents the supplied map
 */
public static TabularData toTabularData(Map<String, MemoryUsage> map) {
    TabularData table = null;
    if (null != map) {
        CompositeType type = getTabularRowType();
        // $NON-NLS-1$ //$NON-NLS-2$
        String[] names = { "key", "value" };
        table = new TabularDataSupport(getTabularType());
        for (Entry<String, MemoryUsage> entry : map.entrySet()) {
            Object[] values = { entry.getKey(), toCompositeData(entry.getValue()) };
            CompositeData row = null;
            try {
                row = new CompositeDataSupport(type, names, values);
            } catch (OpenDataException e) {
                if (ManagementUtils.VERBOSE_MODE) {
                    e.printStackTrace(System.err);
                }
            }
            table.put(row);
        }
    }
    return table;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) MemoryUsage(java.lang.management.MemoryUsage) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 54 with CompositeDataSupport

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

the class ManagementUtils method toSystemPropertiesTabularData.

/**
 * @param propsMap
 *            a <code>Map&lt;String, String%gt;</code> of the system
 *            properties.
 * @return the system properties (e.g. as obtained from
 *         {@link RuntimeMXBean#getSystemProperties()}) wrapped in a
 *         {@link TabularData}.
 */
public static TabularData toSystemPropertiesTabularData(Map<String, String> propsMap) {
    // Bail out early on null input.
    if (propsMap == null) {
        return null;
    }
    TabularData result = null;
    try {
        // Obtain the row type for the TabularType
        // $NON-NLS-1$ //$NON-NLS-2$
        String[] rtItemNames = { "key", "value" };
        // $NON-NLS-1$ //$NON-NLS-2$
        String[] rtItemDescs = { "key", "value" };
        OpenType<?>[] rtItemTypes = { SimpleType.STRING, SimpleType.STRING };
        CompositeType rowType = new CompositeType(propsMap.getClass().getName(), propsMap.getClass().getName(), rtItemNames, rtItemDescs, rtItemTypes);
        // Obtain the required TabularType
        TabularType sysPropsType = new TabularType(propsMap.getClass().getName(), propsMap.getClass().getName(), rowType, // $NON-NLS-1$
        new String[] { "key" });
        // Create an empty TabularData
        result = new TabularDataSupport(sysPropsType);
        // instance of CompositeData and put into the TabularType
        for (Entry<String, String> entry : propsMap.entrySet()) {
            String propKey = entry.getKey();
            String propVal = entry.getValue();
            result.put(new CompositeDataSupport(rowType, rtItemNames, new String[] { propKey, propVal }));
        }
    } catch (OpenDataException e) {
        if (ManagementUtils.VERBOSE_MODE) {
            e.printStackTrace(System.err);
        }
        result = null;
    }
    return result;
}
Also used : OpenType(javax.management.openmbean.OpenType) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 55 with CompositeDataSupport

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

the class MonitorInfoUtil method toCompositeData.

/**
 * @param info a <code>MonitorInfo</code> object
 * @return a new <code>CompositeData</code> instance that represents the supplied <code>info</code> object
 */
public static CompositeData toCompositeData(MonitorInfo info) {
    CompositeData result = null;
    if (info != null) {
        CompositeType type = getCompositeType();
        String[] names = { // $NON-NLS-1$ //$NON-NLS-2$
        "className", // $NON-NLS-1$ //$NON-NLS-2$
        "identityHashCode", "lockedStackFrame", // $NON-NLS-1$ //$NON-NLS-2$
        "lockedStackDepth" };
        Object[] values = { info.getClassName(), Integer.valueOf(info.getIdentityHashCode()), StackTraceElementUtil.toCompositeData(info.getLockedStackFrame()), Integer.valueOf(info.getLockedStackDepth()) };
        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)

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