Java Code Examples for javax.management.openmbean.CompositeData
The following examples show how to use
javax.management.openmbean.CompositeData. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk8u-dev-jdk Source File: VMOptionCompositeData.java License: GNU General Public License v2.0 | 6 votes |
protected CompositeData getCompositeData() { // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH // vmOptionItemNames! final Object[] vmOptionItemValues = { option.getName(), option.getValue(), new Boolean(option.isWriteable()), option.getOrigin().toString(), }; try { return new CompositeDataSupport(vmOptionCompositeType, vmOptionItemNames, vmOptionItemValues); } catch (OpenDataException e) { // Should never reach here throw new AssertionError(e); } }
Example 2
Source Project: dragonwell8_jdk Source File: MXBeanTest.java License: GNU General Public License v2.0 | 6 votes |
private static boolean compositeDataEqual(CompositeData cd1, CompositeData cd2, NamedMXBeans namedMXBeans) { if (cd1 == cd2) return true; if (!cd1.getCompositeType().equals(cd2.getCompositeType())) return false; Collection v1 = cd1.values(); Collection v2 = cd2.values(); if (v1.size() != v2.size()) return false; // should not happen for (Iterator i1 = v1.iterator(), i2 = v2.iterator(); i1.hasNext(); ) { if (!equal(i1.next(), i2.next(), namedMXBeans)) return false; } return true; }
Example 3
Source Project: openjdk-8 Source File: DefaultMXBeanMappingFactory.java License: GNU General Public License v2.0 | 6 votes |
Object fromCompositeData(CompositeData cd, String[] itemNames, MXBeanMapping[] converters) throws InvalidObjectException { Object o; try { final Class<?> targetClass = getTargetClass(); ReflectUtil.checkPackageAccess(targetClass); o = targetClass.newInstance(); for (int i = 0; i < itemNames.length; i++) { if (cd.containsKey(itemNames[i])) { Object openItem = cd.get(itemNames[i]); Object javaItem = converters[i].fromOpenValue(openItem); MethodUtil.invoke(setters[i], o, new Object[] {javaItem}); } } } catch (Exception e) { throw invalidObjectException(e); } return o; }
Example 4
Source Project: openjdk-8-source Source File: MemoryImpl.java License: GNU General Public License v2.0 | 6 votes |
static void createNotification(String notifType, String poolName, MemoryUsage usage, long count) { MemoryImpl mbean = (MemoryImpl) ManagementFactory.getMemoryMXBean(); if (!mbean.hasListeners()) { // if no listener is registered. return; } long timestamp = System.currentTimeMillis(); String msg = getNotifMsg(notifType); Notification notif = new Notification(notifType, mbean.getObjectName(), getNextSeqNumber(), timestamp, msg); MemoryNotificationInfo info = new MemoryNotificationInfo(poolName, usage, count); CompositeData cd = MemoryNotifInfoCompositeData.toCompositeData(info); notif.setUserData(cd); mbean.sendNotification(notif); }
Example 5
Source Project: openjdk-jdk8u Source File: MemoryNotifInfoCompositeData.java License: GNU General Public License v2.0 | 6 votes |
protected CompositeData getCompositeData() { // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH // memoryNotifInfoItemNames! final Object[] memoryNotifInfoItemValues = { memoryNotifInfo.getPoolName(), MemoryUsageCompositeData.toCompositeData(memoryNotifInfo.getUsage()), new Long(memoryNotifInfo.getCount()), }; try { return new CompositeDataSupport(memoryNotifInfoCompositeType, memoryNotifInfoItemNames, memoryNotifInfoItemValues); } catch (OpenDataException e) { // Should never reach here throw new AssertionError(e); } }
Example 6
Source Project: jdk8u-jdk Source File: DefaultMXBeanMappingFactory.java License: GNU General Public License v2.0 | 6 votes |
Object fromCompositeData(CompositeData cd, String[] itemNames, MXBeanMapping[] converters) throws InvalidObjectException { Object o; try { final Class<?> targetClass = getTargetClass(); ReflectUtil.checkPackageAccess(targetClass); o = targetClass.newInstance(); for (int i = 0; i < itemNames.length; i++) { if (cd.containsKey(itemNames[i])) { Object openItem = cd.get(itemNames[i]); Object javaItem = converters[i].fromOpenValue(openItem); MethodUtil.invoke(setters[i], o, new Object[] {javaItem}); } } } catch (Exception e) { throw invalidObjectException(e); } return o; }
Example 7
Source Project: jdk8u-jdk Source File: GarbageCollectorImpl.java License: GNU General Public License v2.0 | 6 votes |
void createGCNotification(long timestamp, String gcName, String gcAction, String gcCause, GcInfo gcInfo) { if (!hasListeners()) { return; } Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION, getObjectName(), getNextSeqNumber(), timestamp, gcName); GarbageCollectionNotificationInfo info = new GarbageCollectionNotificationInfo(gcName, gcAction, gcCause, gcInfo); CompositeData cd = GarbageCollectionNotifInfoCompositeData.toCompositeData(info); notif.setUserData(cd); sendNotification(notif); }
Example 8
Source Project: jdk8u-jdk Source File: DefaultMXBeanMappingFactory.java License: GNU General Public License v2.0 | 6 votes |
@Override final Object fromNonNullOpenValue(Object openValue) throws InvalidObjectException { final TabularData table = (TabularData) openValue; final Collection<CompositeData> rows = cast(table.values()); final Map<Object, Object> valueMap = sortedMap ? newSortedMap() : newInsertionOrderMap(); for (CompositeData row : rows) { final Object key = keyMapping.fromOpenValue(row.get("key")); final Object value = valueMapping.fromOpenValue(row.get("value")); if (valueMap.put(key, value) != null) { final String msg = "Duplicate entry in TabularData: key=" + key; throw new InvalidObjectException(msg); } } return valueMap; }
Example 9
Source Project: openjdk-jdk8u Source File: XMBeanNotifications.java License: GNU General Public License v2.0 | 6 votes |
@Override public String toString() { if (userData == null) { return null; } if (userData.getClass().isArray()) { String name = Utils.getArrayClassName(userData.getClass().getName()); int length = Array.getLength(userData); return name + "[" + length + "]"; } if (userData instanceof CompositeData || userData instanceof TabularData) { return userData.getClass().getName(); } return userData.toString(); }
Example 10
Source Project: jdk8u-jdk Source File: MemoryUsageCompositeData.java License: GNU General Public License v2.0 | 6 votes |
protected CompositeData getCompositeData() { // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH // memoryUsageItemNames! final Object[] memoryUsageItemValues = { new Long(usage.getInit()), new Long(usage.getUsed()), new Long(usage.getCommitted()), new Long(usage.getMax()), }; try { return new CompositeDataSupport(memoryUsageCompositeType, memoryUsageItemNames, memoryUsageItemValues); } catch (OpenDataException e) { // Should never reach here throw new AssertionError(e); } }
Example 11
Source Project: hottub Source File: StackTraceElementCompositeData.java License: GNU General Public License v2.0 | 6 votes |
protected CompositeData getCompositeData() { // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH // stackTraceElementItemNames! final Object[] stackTraceElementItemValues = { ste.getClassName(), ste.getMethodName(), ste.getFileName(), new Integer(ste.getLineNumber()), new Boolean(ste.isNativeMethod()), }; try { return new CompositeDataSupport(stackTraceElementCompositeType, stackTraceElementItemNames, stackTraceElementItemValues); } catch (OpenDataException e) { // Should never reach here throw new AssertionError(e); } }
Example 12
Source Project: openjdk-jdk8u-backup Source File: MemoryUsageCompositeData.java License: GNU General Public License v2.0 | 6 votes |
protected CompositeData getCompositeData() { // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH // memoryUsageItemNames! final Object[] memoryUsageItemValues = { new Long(usage.getInit()), new Long(usage.getUsed()), new Long(usage.getCommitted()), new Long(usage.getMax()), }; try { return new CompositeDataSupport(memoryUsageCompositeType, memoryUsageItemNames, memoryUsageItemValues); } catch (OpenDataException e) { // Should never reach here throw new AssertionError(e); } }
Example 13
Source Project: ignite Source File: JmxExporterSpiTest.java License: Apache License 2.0 | 6 votes |
/** */ private void checkContinuousQueryView(IgniteEx origNode, IgniteEx checkNode) { TabularDataSupport qrys = systemView(checkNode, CQ_SYS_VIEW); assertEquals(1, qrys.size()); for (int i = 0; i < qrys.size(); i++) { CompositeData cq = qrys.get(new Object[] {i}); assertEquals("cache-1", cq.get("cacheName")); assertEquals(100, cq.get("bufferSize")); assertEquals(1000L, cq.get("interval")); assertEquals(origNode.localNode().id().toString(), cq.get("nodeId")); if (origNode.localNode().id().equals(checkNode.localNode().id())) assertTrue(cq.get("localListener").toString().startsWith(getClass().getName())); else assertNull(cq.get("localListener")); assertTrue(cq.get("remoteFilter").toString().startsWith(getClass().getName())); assertNull(cq.get("localTransformedListener")); assertNull(cq.get("remoteTransformer")); } }
Example 14
Source Project: jdk8u60 Source File: ValidateOpenTypes.java License: GNU General Public License v2.0 | 5 votes |
private static String getProperty(TabularData td, String propName) { CompositeData cd = td.get(new Object[] { propName}); if (cd != null) { String key = (String) cd.get("key"); if (!propName.equals(key)) { throw new RuntimeException("TEST FAILED: " + key + " property found" + " but expected to be " + propName); } return (String) cd.get("value"); } return null; }
Example 15
Source Project: hottub Source File: LockInfoCompositeData.java License: GNU General Public License v2.0 | 5 votes |
public static LockInfo toLockInfo(CompositeData cd) { if (cd == null) { throw new NullPointerException("Null CompositeData"); } if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) { throw new IllegalArgumentException( "Unexpected composite type for LockInfo"); } String className = getString(cd, CLASS_NAME); int identityHashCode = getInt(cd, IDENTITY_HASH_CODE); return new LockInfo(className, identityHashCode); }
Example 16
Source Project: jdk8u-jdk Source File: GarbageCollectionNotifInfoCompositeData.java License: GNU General Public License v2.0 | 5 votes |
public static String getGcCause(CompositeData cd) { String gccause = getString(cd, GC_CAUSE); if (gccause == null) { throw new IllegalArgumentException("Invalid composite data: " + "Attribute " + GC_CAUSE + " has null value"); } return gccause; }
Example 17
Source Project: openjdk-8-source Source File: GcInfoCompositeData.java License: GNU General Public License v2.0 | 5 votes |
public static Map<String, MemoryUsage> getMemoryUsageAfterGc(CompositeData cd) { try { TabularData td = (TabularData) cd.get(MEMORY_USAGE_AFTER_GC); //return (Map<String,MemoryUsage>) return cast(memoryUsageMapType.toJavaTypeData(td)); } catch (InvalidObjectException | OpenDataException e) { // Should never reach here throw new AssertionError(e); } }
Example 18
Source Project: jdk8u_jdk Source File: LockInfoCompositeData.java License: GNU General Public License v2.0 | 5 votes |
public static LockInfo toLockInfo(CompositeData cd) { if (cd == null) { throw new NullPointerException("Null CompositeData"); } if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) { throw new IllegalArgumentException( "Unexpected composite type for LockInfo"); } String className = getString(cd, CLASS_NAME); int identityHashCode = getInt(cd, IDENTITY_HASH_CODE); return new LockInfo(className, identityHashCode); }
Example 19
Source Project: jdk1.8-source-analysis Source File: MemoryUsage.java License: Apache License 2.0 | 5 votes |
/** * Constructs a <tt>MemoryUsage</tt> object from a * {@link CompositeData CompositeData}. */ private MemoryUsage(CompositeData cd) { // validate the input composite data MemoryUsageCompositeData.validateCompositeData(cd); this.init = MemoryUsageCompositeData.getInit(cd); this.used = MemoryUsageCompositeData.getUsed(cd); this.committed = MemoryUsageCompositeData.getCommitted(cd); this.max = MemoryUsageCompositeData.getMax(cd); }
Example 20
Source Project: TencentKona-8 Source File: ConfigurationInfo.java License: GNU General Public License v2.0 | 5 votes |
private ConfigurationInfo(CompositeData cd) { this.settings = createMap(cd.get("settings")); this.name = (String) cd.get("name"); this.label = (String) cd.get("label"); this.description = (String) cd.get("description"); this.provider = (String) cd.get("provider"); this.contents = (String) cd.get("contents"); }
Example 21
Source Project: jdk8u-dev-jdk Source File: ThreadInfoCompositeData.java License: GNU General Public License v2.0 | 5 votes |
public MonitorInfo[] lockedMonitors() { CompositeData[] lockedMonitorsData = (CompositeData[]) cdata.get(LOCKED_MONITORS); // The LockedMonitors item cannot be null, but if it is we will get // a NullPointerException when we ask for its length. MonitorInfo[] monitors = new MonitorInfo[lockedMonitorsData.length]; for (int i = 0; i < lockedMonitorsData.length; i++) { CompositeData cdi = lockedMonitorsData[i]; monitors[i] = MonitorInfo.from(cdi); } return monitors; }
Example 22
Source Project: openjdk-8 Source File: GarbageCollectionNotifInfoCompositeData.java License: GNU General Public License v2.0 | 5 votes |
public static String getGcName(CompositeData cd) { String gcname = getString(cd, GC_NAME); if (gcname == null) { throw new IllegalArgumentException("Invalid composite data: " + "Attribute " + GC_NAME + " has null value"); } return gcname; }
Example 23
Source Project: openjdk-8 Source File: ValidateOpenTypes.java License: GNU General Public License v2.0 | 5 votes |
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); } } }
Example 24
Source Project: openjdk-8 Source File: MemoryNotifInfoCompositeData.java License: GNU General Public License v2.0 | 5 votes |
public static String getPoolName(CompositeData cd) { String poolname = getString(cd, POOL_NAME); if (poolname == null) { throw new IllegalArgumentException("Invalid composite data: " + "Attribute " + POOL_NAME + " has null value"); } return poolname; }
Example 25
Source Project: jdk8u60 Source File: AttributeArbitraryDataTypeTest.java License: GNU General Public License v2.0 | 5 votes |
public CompositeData getCompositeDataAttribute() throws OpenDataException { CompositeType ct = new CompositeType("CompositeDataAttribute", "Composite Data Attribute", itemNames, itemDescriptions, itemTypes); Object itemValues[] = { ia, da, sa }; return new CompositeDataSupport(ct, itemNames, itemValues); }
Example 26
Source Project: baratine Source File: MemoryPoolAdapter.java License: GNU General Public License v2.0 | 5 votes |
public long getCodeCacheFree() throws JMException { CompositeData data = (CompositeData) _mbeanServer.getAttribute(getCodeCacheName(), "Usage"); MemoryUsage usage = MemoryUsage.from(data); return usage.getMax() - usage.getUsed(); }
Example 27
Source Project: javamail Source File: JavaMailJMSStatistics.java License: Apache License 2.0 | 5 votes |
private static CompositeData convert(MessageAndAddresses maa) { if (maa == null) { return null; } try { TabularData addrData = new TabularDataSupport(TAB_ADDR_TYPE); for(Address addr : maa.getAddresses()) { addrData.put(new CompositeDataSupport(ROW_ADDR_TYPE, new String[]{"addressType", "address"}, new Object[]{addr.getType(), addr.toString()})); } TabularData headerData = new TabularDataSupport(TAB_HEADER_TYPE); Enumeration en = maa.getMessage().getAllHeaders(); while (en.hasMoreElements()) { Header header = (Header) en.nextElement(); headerData.put(new CompositeDataSupport(ROW_HEADER_TYPE, new String[]{"header-name", "header-value"}, new Object[]{header.getName(), header.getValue()})); } String error = null; if (maa.getException() != null) { StringWriter sw = new StringWriter(); sw.append(maa.getException().toString()); maa.getException().printStackTrace(new PrintWriter(sw)); sw.flush(); error = sw.toString(); } return new CompositeDataSupport(MAIL_INFO_TYPE, new String[] {"messageId", "date", "subject", "toAddresses", "headers", "errorDescription"}, new Object[]{maa.getMessage().getMessageID(), new Date(maa.getTimestamp()), maa.getMessage().getSubject(), addrData, headerData, error} ); } catch (OpenDataException | MessagingException e) { throw new IllegalArgumentException("cannot convert MessageAndAddresses to CompositeData", e); } }
Example 28
Source Project: Tomcat7.0.67 Source File: JMXProxyServlet.java License: Apache License 2.0 | 5 votes |
public void getAttribute(PrintWriter writer, String onameStr, String att, String key) { try { ObjectName oname = new ObjectName(onameStr); Object value = mBeanServer.getAttribute(oname, att); if(null != key && value instanceof CompositeData) value = ((CompositeData)value).get(key); String valueStr; if (value != null) { valueStr = value.toString(); } else { valueStr = "<null>"; } writer.print("OK - Attribute get '"); writer.print(onameStr); writer.print("' - "); writer.print(att); if(null != key) { writer.print(" - key '"); writer.print(key); writer.print("'"); } writer.print(" = "); writer.println(MBeanDumper.escape(valueStr)); } catch (Exception ex) { writer.println("Error - " + ex.toString()); ex.printStackTrace(writer); } }
Example 29
Source Project: jdk8u-dev-jdk Source File: MXBeanTest.java License: GNU General Public License v2.0 | 5 votes |
static boolean equal(Object o1, Object o2, NamedMXBeans namedMXBeans) { if (o1 == o2) return true; if (o1 == null || o2 == null) return false; if (o1.getClass().isArray()) { if (!o2.getClass().isArray()) return false; return deepEqual(o1, o2, namedMXBeans); } if (o1 instanceof Map) { if (!(o2 instanceof Map)) return false; return equalMap((Map) o1, (Map) o2, namedMXBeans); } if (o1 instanceof CompositeData && o2 instanceof CompositeData) { return compositeDataEqual((CompositeData) o1, (CompositeData) o2, namedMXBeans); } if (Proxy.isProxyClass(o1.getClass())) { if (Proxy.isProxyClass(o2.getClass())) return proxyEqual(o1, o2, namedMXBeans); InvocationHandler ih = Proxy.getInvocationHandler(o1); // if (ih instanceof MXBeanInvocationHandler) { // return proxyEqualsObject((MXBeanInvocationHandler) ih, // o2, namedMXBeans); if (ih instanceof MBeanServerInvocationHandler) { return true; } else if (ih instanceof CompositeDataInvocationHandler) { return o2.equals(o1); // We assume the other object has a reasonable equals method } } else if (Proxy.isProxyClass(o2.getClass())) return equal(o2, o1, namedMXBeans); return o1.equals(o2); }
Example 30
Source Project: jdk8u-dev-jdk Source File: LowMemoryTest2.java License: GNU General Public License v2.0 | 5 votes |
public void handleNotification(Notification notif, Object handback) { String type = notif.getType(); if (type.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED) || type.equals(MemoryNotificationInfo. MEMORY_COLLECTION_THRESHOLD_EXCEEDED)) { listenerInvoked = true; MemoryNotificationInfo minfo = MemoryNotificationInfo. from((CompositeData) notif.getUserData()); System.out.print("Notification for " + minfo.getPoolName()); System.out.print(" [type = " + type); System.out.println(" count = " + minfo.getCount() + "]"); System.out.println(INDENT + "usage = " + minfo.getUsage()); } }