Search in sources :

Example 36 with CompositeData

use of javax.management.openmbean.CompositeData in project jdk8u_jdk by JetBrains.

the class CompositeDataStringTest method main.

public static void main(String[] args) throws Exception {
    CompositeType basicCT = new CompositeType("basicCT", "basic CompositeType", new String[] { "name", "value" }, new String[] { "name", "value" }, new OpenType<?>[] { SimpleType.STRING, SimpleType.INTEGER });
    CompositeType ct = new CompositeType("noddy", "descr", new String[] { "strings", "ints", "cds" }, new String[] { "string array", "int array", "composite data array" }, new OpenType<?>[] { ArrayType.getArrayType(SimpleType.STRING), ArrayType.getPrimitiveArrayType(int[].class), ArrayType.getArrayType(basicCT) });
    CompositeData basicCD1 = new CompositeDataSupport(basicCT, new String[] { "name", "value" }, new Object[] { "ceathar", 4 });
    CompositeData basicCD2 = new CompositeDataSupport(basicCT, new String[] { "name", "value" }, new Object[] { "naoi", 9 });
    CompositeData cd = new CompositeDataSupport(ct, new String[] { "strings", "ints", "cds" }, new Object[] { new String[] { "fred", "jim", "sheila" }, new int[] { 2, 3, 5, 7 }, new CompositeData[] { basicCD1, basicCD2 } });
    String s = cd.toString();
    System.out.println("CompositeDataSupport.toString(): " + s);
    String[] expected = { "fred, jim, sheila", "2, 3, 5, 7", "ceathar", "naoi" };
    boolean ok = true;
    for (String expect : expected) {
        if (s.contains(expect))
            System.out.println("OK: string contains <" + expect + ">");
        else {
            ok = false;
            System.out.println("NOT OK: string does not contain <" + expect + ">");
        }
    }
    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("TEST FAILED: string did not contain expected substrings");
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 37 with CompositeData

use of javax.management.openmbean.CompositeData in project jdk8u_jdk by JetBrains.

the class TabularDataOrderTest method makeTable.

private static TabularData makeTable() throws OpenDataException {
    TabularData td = new TabularDataSupport(tt);
    for (Map.Entry<String, Integer> entry : stringToValue.entrySet()) {
        CompositeData cd = new CompositeDataSupport(ct, new String[] { "name", "int" }, new Object[] { entry.getKey(), entry.getValue() });
        td.put(cd);
    }
    return td;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TabularData(javax.management.openmbean.TabularData)

Example 38 with CompositeData

use of javax.management.openmbean.CompositeData in project jdk8u_jdk by JetBrains.

the class ValidateOpenTypes method checkSunGC.

private static void checkSunGC() throws Exception {
    // Test com.sun.management proxy
    List<GarbageCollectorMXBean> gcs = getGarbageCollectorMXBeans();
    for (GarbageCollectorMXBean gc : gcs) {
        ObjectName sunGc = new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=" + gc.getName());
        CompositeData cd = (CompositeData) server.getAttribute(sunGc, "LastGcInfo");
        if (cd != null) {
            System.out.println("GC statistic for : " + gc.getName());
            printGcInfo(cd);
        }
    }
}
Also used : CompositeData(javax.management.openmbean.CompositeData)

Example 39 with CompositeData

use of javax.management.openmbean.CompositeData in project tdi-studio-se by Talend.

the class DumpHprofAction method getInitialFileName.

/**
     * Gets the initial file name.
     * 
     * @param jvm The active JVM
     * @return The file name, or <tt>null</tt> if file name is specified
     * @throws JvmCoreException
     */
String getInitialFileName(IActiveJvm jvm) throws JvmCoreException {
    ObjectName objectName;
    try {
        objectName = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
    } catch (MalformedObjectNameException e) {
        throw new JvmCoreException(IStatus.ERROR, e.getMessage(), e);
    } catch (NullPointerException e) {
        throw new JvmCoreException(IStatus.ERROR, e.getMessage(), e);
    }
    //$NON-NLS-1$
    TabularData initialName = (TabularData) jvm.getMBeanServer().getAttribute(objectName, "SystemProperties");
    //$NON-NLS-1$
    CompositeData compisiteData = initialName.get(new Object[] { "user.home" });
    String home = compisiteData.values().toArray(new String[0])[1];
    StringBuffer initialFileName = new StringBuffer(home);
    initialFileName.append(File.separator).append(new Date().getTime()).append('.').append(SnapshotType.Hprof.getExtension());
    return initialFileName.toString();
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CompositeData(javax.management.openmbean.CompositeData) Date(java.util.Date) ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException) TabularData(javax.management.openmbean.TabularData)

Example 40 with CompositeData

use of javax.management.openmbean.CompositeData in project tdi-studio-se by Talend.

the class CpuProfiler method getTransformStatusCompositeValue.

/**
     * Gets the composite value of transform status corresponding to the given composite key.
     * 
     * @param compositeKey The composite key
     * @return The composite value
     * @throws JvmCoreException
     */
private int getTransformStatusCompositeValue(String compositeKey) throws JvmCoreException {
    ObjectName objectName = jvm.getMBeanServer().getObjectName(PROFILER_MXBEAN_NAME);
    Object attribute = jvm.getMBeanServer().getAttribute(objectName, TRANSFORM_STATUS);
    if (attribute instanceof CompositeData) {
        Object element = ((CompositeData) attribute).get(compositeKey);
        if (element instanceof Integer) {
            return (Integer) element;
        }
    }
    throw new IllegalStateException();
}
Also used : CompositeData(javax.management.openmbean.CompositeData) ObjectName(javax.management.ObjectName)

Aggregations

CompositeData (javax.management.openmbean.CompositeData)229 TabularData (javax.management.openmbean.TabularData)91 Test (org.junit.Test)73 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)68 TabularDataSupport (javax.management.openmbean.TabularDataSupport)51 CompositeType (javax.management.openmbean.CompositeType)50 HashMap (java.util.HashMap)31 ArrayList (java.util.ArrayList)27 Map (java.util.Map)27 Bundle (org.osgi.framework.Bundle)24 ObjectName (javax.management.ObjectName)21 OpenDataException (javax.management.openmbean.OpenDataException)18 IOException (java.io.IOException)17 Collection (java.util.Collection)16 AbstractIntegrationTest (org.apache.aries.jmx.AbstractIntegrationTest)16 AuditEvent (org.nhindirect.common.audit.AuditEvent)15 TabularType (javax.management.openmbean.TabularType)13 MBeanServer (javax.management.MBeanServer)12 DefaultAuditContext (org.nhindirect.common.audit.DefaultAuditContext)11 MBeanException (javax.management.MBeanException)8