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");
}
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;
}
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);
}
}
}
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();
}
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();
}
Aggregations