001: /*_############################################################################
002: _##
003: _## SNMP4J-AgentJMX - JvmManagementMibInst.java
004: _##
005: _## Copyright (C) 2006-2007 Frank Fock (SNMP4J.org)
006: _##
007: _## This program is free software; you can redistribute it and/or modify
008: _## it under the terms of the GNU General Public License version 2 as
009: _## published by the Free Software Foundation.
010: _##
011: _## This program is distributed in the hope that it will be useful,
012: _## but WITHOUT ANY WARRANTY; without even the implied warranty of
013: _## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: _## GNU General Public License for more details.
015: _##
016: _## You should have received a copy of the GNU General Public License
017: _## along with this program; if not, write to the Free Software
018: _## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
019: _## MA 02110-1301 USA
020: _##
021: _##########################################################################*/
022:
023: package org.snmp4j.agent.mo.jmx.mibs;
024:
025: import java.io.File;
026: import java.lang.management.ManagementFactory;
027: import java.lang.management.MemoryType;
028: import java.util.Arrays;
029: import java.util.HashMap;
030: import java.util.Map;
031: import javax.management.MBeanServerConnection;
032: import javax.management.MalformedObjectNameException;
033: import javax.management.ObjectName;
034:
035: import org.snmp4j.agent.*;
036: import org.snmp4j.agent.mo.MOScalar;
037: import org.snmp4j.agent.mo.jmx.*;
038: import org.snmp4j.agent.mo.jmx.MBeanNotificationInfo;
039: import org.snmp4j.agent.mo.jmx.types.*;
040: import org.snmp4j.agent.mo.jmx.util.AbstractSyntheticJMXIndexSupport;
041: import org.snmp4j.agent.mo.snmp.smi.EnumerationConstraint;
042: import org.snmp4j.agent.mo.snmp.smi.ValueConstraint;
043: import org.snmp4j.agent.mo.snmp.smi.ValueConstraintValidator;
044: import org.snmp4j.smi.Counter64;
045: import org.snmp4j.smi.OID;
046: import org.snmp4j.smi.OctetString;
047: import org.snmp4j.smi.Variable;
048:
049: /**
050: * The <code>JvmManagementMibInst</code> demonstrates how an AgenPro generated
051: * MIB module class can be extended to provide JMX instrumentation for it. The
052: * instrumentation is done mostly descriptive. Only for value mapping some code
053: * is necessary.
054: *
055: * @author Frank Fock
056: * @version 1.0
057: */
058: public class JvmManagementMibInst extends JvmManagementMib {
059:
060: private static final OID[] ACTION_OIDS = new OID[] { JvmManagementMib.oidJvmMemoryGCCall };
061:
062: private static final MBeanNotificationObjectInfo[] jvmLowMemoryPoolUsageNotif = new MBeanNotificationObjectInfo[] {
063: new MBeanNotificationObjectInfo(new OID(
064: JvmManagementMib.oidJvmMemPoolEntry.getValue(),
065: new int[] { JvmManagementMib.colJvmMemPoolName }),
066: new OctetString(), new TypedAttribute("poolName",
067: String.class)),
068: new MBeanNotificationObjectInfo(new OID(
069: JvmManagementMib.oidJvmMemPoolEntry.getValue(),
070: new int[] { JvmManagementMib.colJvmMemPoolUsed }),
071: new Counter64(), new TypedCompositeDataAttribute(
072: "usage", "used", Long.class)),
073: new MBeanNotificationObjectInfo(
074: new OID(
075: JvmManagementMib.oidJvmMemPoolEntry
076: .getValue(),
077: new int[] { JvmManagementMib.colJvmMemPoolThreshdCount }),
078: new Counter64(), new TypedAttribute("count",
079: Long.class)) };
080:
081: private static final MBeanNotificationObjectInfo[] jvmLowMemoryPoolCollectNotif = new MBeanNotificationObjectInfo[] {
082: new MBeanNotificationObjectInfo(new OID(
083: JvmManagementMib.oidJvmMemPoolEntry.getValue(),
084: new int[] { JvmManagementMib.colJvmMemPoolName }),
085: new OctetString(), new TypedAttribute("poolName",
086: String.class)),
087: new MBeanNotificationObjectInfo(
088: new OID(
089: JvmManagementMib.oidJvmMemPoolEntry
090: .getValue(),
091: new int[] { JvmManagementMib.colJvmMemPoolCollectUsed }),
092: new Counter64(), new TypedCompositeDataAttribute(
093: "usage", "used", Long.class)),
094: new MBeanNotificationObjectInfo(
095: new OID(
096: JvmManagementMib.oidJvmMemPoolEntry
097: .getValue(),
098: new int[] { JvmManagementMib.colJvmMemPoolCollectThreshdCount }),
099: new Counter64(), new TypedAttribute("count",
100: Long.class)) };
101:
102: private static final Object[][] SCALAR_MBEANS_JVM_MEMORY_ACTIONS = { {
103: JvmManagementMib.oidJvmMemoryGCCall,
104: new MBeanStateInfo[] { new MBeanStateInfo(2, null, null) },
105: new MBeanActionInfo[] { new MBeanActionInfo(3, "gc",
106: new Object[0]) } } };
107:
108: private static final Object[][] SCALAR_MBEANS_JVM_MEMORY = {
109: { JvmManagementMib.oidJvmMemoryPendingFinalCount,
110: "ObjectPendingFinalizationCount", Long.class },
111: { JvmManagementMib.oidJvmMemoryGCVerboseLevel,
112: new InverseBooleanType("Verbose") },
113: // { JvmManagementMib.oidJvmMemoryGCCall, "VmVendor", String.class },
114: {
115: JvmManagementMib.oidJvmMemoryHeapInitSize,
116: new TypedCompositeDataAttribute("HeapMemoryUsage",
117: "init", Long.class) },
118: {
119: JvmManagementMib.oidJvmMemoryHeapUsed,
120: new TypedCompositeDataAttribute("HeapMemoryUsage",
121: "used", Long.class) },
122: {
123: JvmManagementMib.oidJvmMemoryHeapCommitted,
124: new TypedCompositeDataAttribute("HeapMemoryUsage",
125: "committed", Long.class) },
126: {
127: JvmManagementMib.oidJvmMemoryHeapMaxSize,
128: new TypedCompositeDataAttribute("HeapMemoryUsage",
129: "max", Long.class) },
130:
131: {
132: JvmManagementMib.oidJvmMemoryNonHeapInitSize,
133: new TypedCompositeDataAttribute(
134: "NonHeapMemoryUsage", "init", Long.class) },
135: {
136: JvmManagementMib.oidJvmMemoryNonHeapUsed,
137: new TypedCompositeDataAttribute(
138: "NonHeapMemoryUsage", "used", Long.class) },
139: {
140: JvmManagementMib.oidJvmMemoryNonHeapCommitted,
141: new TypedCompositeDataAttribute(
142: "NonHeapMemoryUsage", "committed",
143: Long.class) },
144: {
145: JvmManagementMib.oidJvmMemoryNonHeapMaxSize,
146: new TypedCompositeDataAttribute(
147: "NonHeapMemoryUsage", "max", Long.class) }
148:
149: };
150:
151: private static final Object[][] SCALAR_MBEANS_JVM_CLASSES = {
152: { JvmManagementMib.oidJvmClassesLoadedCount,
153: "LoadedClassCount", Integer.class },
154: { JvmManagementMib.oidJvmClassesTotalLoadedCount,
155: "TotalLoadedClassCount", Long.class },
156: { JvmManagementMib.oidJvmClassesUnloadedCount,
157: "UnloadedClassCount", Long.class },
158: { JvmManagementMib.oidJvmClassesVerboseLevel,
159: new InverseBooleanType("Verbose") }, };
160:
161: private static final Object[][] SCALAR_MBEANS_JVM_RUNTIME = {
162: { JvmManagementMib.oidJvmRTName, "Name", String.class },
163: { JvmManagementMib.oidJvmRTVMName, "VmName", String.class },
164: { JvmManagementMib.oidJvmRTVMVendor, "VmVendor",
165: String.class },
166: { JvmManagementMib.oidJvmRTVMVersion, "VmVersion",
167: String.class },
168: { JvmManagementMib.oidJvmRTSpecName, "SpecName",
169: String.class },
170: { JvmManagementMib.oidJvmRTSpecVendor, "SpecVendor",
171: String.class },
172: { JvmManagementMib.oidJvmRTSpecVersion, "SpecVersion",
173: String.class },
174: { JvmManagementMib.oidJvmRTManagementSpecVersion,
175: "ManagementSpecVersion", String.class },
176: { JvmManagementMib.oidJvmRTBootClassPathSupport,
177: new InverseBooleanType("BootClassPathSupported") },
178: { JvmManagementMib.oidJvmRTInputArgsCount,
179: "InputArguments", Long.class },
180: { JvmManagementMib.oidJvmRTUptimeMs, "Uptime", Long.class },
181: { JvmManagementMib.oidJvmRTStartTimeMs, "StartTime",
182: Long.class }
183:
184: };
185:
186: private static final Object[][] SCALAR_MBEANS_JIT_COMPILER = {
187: { JvmManagementMib.oidJvmJITCompilerName, "Name",
188: String.class },
189: { JvmManagementMib.oidJvmJITCompilerTimeMs,
190: "TotalCompilationTime", Long.class },
191: {
192: JvmManagementMib.oidJvmJITCompilerTimeMonitoring,
193: new InverseBooleanType(
194: "CompilationTimeMonitoringSupported") } };
195:
196: private static final Object[][] SCALAR_MBEANS_JVM_OS = {
197: { JvmManagementMib.oidJvmOSName, "Name", String.class },
198: { JvmManagementMib.oidJvmOSArch, "Arch", String.class },
199: { JvmManagementMib.oidJvmOSVersion, "Version", String.class },
200: { JvmManagementMib.oidJvmOSProcessorCount,
201: "AvailableProcessors", Integer.class } };
202:
203: private static final Object[][] SCALAR_MBEANS_JVM_THREADING = {
204: { JvmManagementMib.oidJvmThreadCount, "ThreadCount",
205: Integer.class },
206: { JvmManagementMib.oidJvmThreadDaemonCount,
207: "DaemonThreadCount", Integer.class },
208: { JvmManagementMib.oidJvmThreadPeakCount,
209: "PeakThreadCount", Integer.class },
210: { JvmManagementMib.oidJvmThreadTotalStartedCount,
211: "TotalStartedThreadCount", Integer.class },
212: { JvmManagementMib.oidJvmThreadPeakCount,
213: "PeakThreadCount", Integer.class },
214: {
215: JvmManagementMib.oidJvmThreadContentionMonitoring,
216: new CombinedTypedAttribute(
217: "",
218: Integer.class,
219: new TypedAttribute[] {
220: new Boolean2IntegerType(
221: "ThreadContentionMonitoringSupported",
222: null, new Integer(1)),
223: new Boolean2IntegerType(
224: "ThreadContentionMonitoringEnabled",
225: new Integer(3),
226: new Integer(4)) }) },
227: {
228: JvmManagementMib.oidJvmThreadCpuTimeMonitoring,
229: new CombinedTypedAttribute("", Integer.class,
230: new TypedAttribute[] {
231: new Boolean2IntegerType(
232: "ThreadCpuTimeSupported",
233: null, new Integer(1)),
234: new Boolean2IntegerType(
235: "ThreadCpuTimeEnabled",
236: new Integer(3),
237: new Integer(4)) }) } };
238:
239: private NotificationOriginator notificationOriginator;
240:
241: public JvmManagementMibInst(
242: NotificationOriginator notificationOriginator) {
243: super ();
244: this .notificationOriginator = notificationOriginator;
245: addJvmManagementMibInstrumentaton();
246: }
247:
248: class TimeAction extends TypedAttribute {
249:
250: private Map values = new HashMap();
251: private MBeanServerConnection server;
252: private String action;
253:
254: public TimeAction(String name, String action,
255: MBeanServerConnection server) {
256: // name of a dummy attribute that is not really used
257: super (name, Long.class);
258: this .server = server;
259: this .action = action;
260: }
261:
262: public boolean isNativeValueAlwaysNeeded() {
263: return true;
264: }
265:
266: public Object transformToNative(Object transformedValue,
267: Object oldNativeValue, ObjectName objectName) {
268: Long nl = (Long) transformedValue;
269: Long ol = (Long) values.get(objectName);
270: if ((ol == null) || (nl > ol)) {
271: try {
272: values.put(objectName, new Long(System
273: .currentTimeMillis()));
274: server.invoke(objectName, action, null, null);
275: } catch (Exception ex) {
276: ex.printStackTrace();
277: }
278: }
279: // supress setting of the dummy attribute we use by returning null here
280: return null;
281: }
282:
283: public Object transformFromNative(Object nativeValue,
284: ObjectName objectName) {
285: Long value = (Long) values.get(objectName);
286: if (value == null) {
287: return new Long(0);
288: }
289: return value;
290: }
291:
292: }
293:
294: public void registerMOs(MOServer server, OctetString context)
295: throws DuplicateRegistrationException {
296: super .registerMOs(server, context);
297: if (server instanceof DefaultMOServer) {
298: addJvmManagementMibConstraints((DefaultMOServer) server);
299: }
300: }
301:
302: private void addJvmManagementMibInstrumentaton() {
303: final MBeanServerConnection server = ManagementFactory
304: .getPlatformMBeanServer();
305:
306: final MBeanAttributeMOTableSupport tableSupport = new MBeanAttributeMOTableSupport(
307: server);
308: final MBeanAttributeMOScalarSupport scalarSupport = new MBeanAttributeMOScalarSupport(
309: server);
310: final MBeanActionMOScalarSupport scalarSupportActions = new MBeanActionMOScalarSupport(
311: server);
312: final JMXNotificationSupport notificationSupport = new JMXNotificationSupport(
313: notificationOriginator);
314:
315: JMXDefaultMOFactory jmxFactory = new JMXDefaultMOFactory(
316: server, scalarSupport) {
317: public MOScalar createScalar(OID id, MOAccess access,
318: Variable value) {
319: if (Arrays.binarySearch(ACTION_OIDS, id) >= 0) {
320: return new MOScalarJMX(scalarSupportActions, id,
321: access, value);
322: }
323: return super .createScalar(id, access, value);
324: }
325: };
326: // create MOs with factory
327: createMO(jmxFactory);
328:
329: try {
330: ObjectName onameJvmMemManagerEntry = new ObjectName(
331: ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
332: + ",*");
333:
334: JMXIndexSupport jvmMemManagerIndexSupport = new AbstractSyntheticJMXIndexSupport() {
335: public ObjectName mapToRowMBean(Object rowIdentifier) {
336: try {
337: return new ObjectName(
338: ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
339: + ",name=" + rowIdentifier);
340: } catch (Exception ex) {
341: ex.printStackTrace();
342: return null;
343: }
344: }
345: };
346:
347: tableSupport.add(super .oidJvmMemManagerEntry,
348: new MBeanAttributeMOTableInfo(
349: onameJvmMemManagerEntry, null,
350: new TypedAttribute[] {
351: new TypedAttribute("Name",
352: String.class),
353: new InverseBooleanType("Valid") },
354: new String[] { "Name" },
355: jvmMemManagerIndexSupport));
356:
357: ObjectName onameJvmMem = new ObjectName(
358: ManagementFactory.MEMORY_MXBEAN_NAME);
359: notificationSupport.add(
360: JvmManagementMib.oidJvmLowMemoryPoolUsageNotif,
361: new MBeanNotificationInfo(
362: jvmLowMemoryPoolUsageNotif,
363: new JMXAttributeNotificationIndexSupport(
364: new TypedAttribute("poolName",
365: String.class),
366: jvmMemManagerIndexSupport)));
367: try {
368: server.addNotificationListener(onameJvmMem,
369: notificationSupport, null,
370: JvmManagementMib.oidJvmLowMemoryPoolUsageNotif);
371: } catch (Exception ex) {
372: ex.printStackTrace();
373: }
374: notificationSupport.add(
375: JvmManagementMib.oidJvmLowMemoryPoolCollectNotif,
376: new MBeanNotificationInfo(
377: jvmLowMemoryPoolCollectNotif,
378: new JMXAttributeNotificationIndexSupport(
379: new TypedAttribute("poolName",
380: String.class),
381: jvmMemManagerIndexSupport)));
382: try {
383: server
384: .addNotificationListener(
385: onameJvmMem,
386: notificationSupport,
387: null,
388: JvmManagementMib.oidJvmLowMemoryPoolCollectNotif);
389: } catch (Exception ex) {
390: ex.printStackTrace();
391: }
392:
393: ObjectName onameJvmMemPoolEntry = new ObjectName(
394: ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE
395: + ",*");
396:
397: tableSupport
398: .add(
399: super .oidJvmMemPoolEntry,
400: new MBeanAttributeMOTableInfo(
401: onameJvmMemPoolEntry,
402: null,
403: new TypedAttribute[] {
404: new TypedAttribute("Name",
405: String.class),
406: new EnumStringType("Type",
407: MemoryType.class,
408: MemoryType.values()),
409: new InverseBooleanType(
410: "Valid"),
411: new TimeAction("Name",
412: "resetPeakUsage",
413: server),
414: new TypedCompositeDataAttribute(
415: "Usage", "init",
416: Long.class),
417: new TypedCompositeDataAttribute(
418: "Usage", "used",
419: Long.class),
420: new TypedCompositeDataAttribute(
421: "Usage",
422: "committed",
423: Long.class),
424: new TypedCompositeDataAttribute(
425: "Usage", "max",
426: Long.class),
427: new TypedCompositeDataAttribute(
428: "PeakUsage",
429: "used", Long.class),
430: new TypedCompositeDataAttribute(
431: "PeakUsage",
432: "committed",
433: Long.class),
434: new TypedCompositeDataAttribute(
435: "PeakUsage", "max",
436: Long.class),
437: new TypedCompositeDataAttribute(
438: "CollectionUsage",
439: "used", Long.class),
440: new TypedCompositeDataAttribute(
441: "CollectionUsage",
442: "committed",
443: Long.class),
444: new TypedCompositeDataAttribute(
445: "CollectionUsage",
446: "max", Long.class),
447: new TypedAttribute(
448: "UsageThreshold",
449: Long.class),
450: new TypedAttribute(
451: "UsageThresholdCount",
452: Long.class),
453: new InverseBooleanType(
454: "UsageThresholdSupported"),
455: new TypedAttribute(
456: "CollectionUsageThreshold",
457: Long.class),
458: new TypedAttribute(
459: "CollectionUsageThresholdCount",
460: Long.class),
461: new InverseBooleanType(
462: "CollectionUsageThresholdSupported") },
463: new String[] { "Name" },
464: new AbstractSyntheticJMXIndexSupport() {
465: public ObjectName mapToRowMBean(
466: Object rowIdentifier) {
467: try {
468: return new ObjectName(
469: ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE
470: + ",name="
471: + rowIdentifier);
472: } catch (Exception ex) {
473: ex.printStackTrace();
474: return null;
475: }
476: }
477: }));
478:
479: ObjectName onameJvmThreading = new ObjectName(
480: ManagementFactory.THREAD_MXBEAN_NAME);
481:
482: tableSupport
483: .add(
484: super .oidJvmThreadInstanceEntry,
485: new MBeanAttributeMOTableInfo(
486: onameJvmThreading,
487: new MBeanInvokationKeyProvider(
488: onameJvmThreading,
489: new TypedAttribute(
490: "AllThreadIds",
491: long.class),
492: "getThreadInfo", true),
493: new TypedAttribute[] {
494: new TypedCompositeDataAttribute(
495: new TypedAttribute(
496: "threadId",
497: Long.class)),
498: new CombinedBitsType(
499: new TypedAttribute[] {
500: new EnumBitsType(
501: "threadState",
502: Thread.State.class,
503: Thread.State
504: .values(),
505: 3),
506: new BooleanBitsType(
507: "inNative",
508: 1),
509: new BooleanBitsType(
510: "suspended",
511: 2) }),
512: new TypedCompositeDataAttribute(
513: new TypedAttribute(
514: "blockedCount",
515: Long.class)),
516: new TypedCompositeDataAttribute(
517: new TypedAttribute(
518: "blockedTime",
519: Long.class)),
520: new TypedCompositeDataAttribute(
521: new TypedAttribute(
522: "waitedCount",
523: Long.class)),
524: new TypedCompositeDataAttribute(
525: new TypedAttribute(
526: "waitedTime",
527: Long.class)),
528: new MBeanProxyType(
529: server,
530: onameJvmThreading,
531: Long.class,
532: "getThreadUserTime",
533: new TypedCompositeDataAttribute(
534: new TypedAttribute(
535: "threadId",
536: long.class))) {
537: public Object transformFromNative(
538: Object nativeValue,
539: ObjectName objectName) {
540: Long result = (Long) super
541: .transformFromNative(
542: nativeValue,
543: objectName);
544: if ((result == null)
545: || (result
546: .longValue() < 0)) {
547: return 0L;
548: }
549: return result;
550: }
551: },
552: new TypedCompositeDataAttribute(
553: new TypedAttribute(
554: "threadName",
555: String.class)),
556: new TypedCompositeDataAttribute(
557: new TypedAttribute(
558: "lockOwnerName",
559: String.class)),
560: new TypedCompositeDataAttribute(
561: new TypedAttribute(
562: "lockOwnerId",
563: Long.class)) {
564: public Object transformFromNative(
565: Object nativeValue,
566: ObjectName objectName) {
567: Long result = (Long) super
568: .transformFromNative(
569: nativeValue,
570: objectName);
571: if ((result == null)
572: || (result
573: .longValue() < 0)) {
574: return "0.0";
575: }
576: OID rowPointer = new OID(
577: JvmManagementMib.oidJvmThreadInstanceEntry);
578: rowPointer
579: .append(JvmManagementMib.colJvmThreadInstId);
580: String index = Long
581: .toHexString(result
582: .longValue());
583: OctetString os = new OctetString();
584: os
585: .fromHexString(index);
586: rowPointer
587: .append(os
588: .toSubIndex(true));
589: return rowPointer
590: .toString();
591: }
592: } },
593: new String[] { "ThreadId" },
594: new JMXIndexSupport() {
595: public ObjectName mapToRowMBean(
596: Object rowIdentifier) {
597: return null;
598: }
599:
600: public Object getRowIdentifier(
601: Object nativeRowId,
602: int nativeIndex) {
603: return nativeRowId;
604: }
605:
606: public OID mapToIndex(
607: Object rowIdentifier) {
608: Long l = (Long) rowIdentifier;
609: return OctetString
610: .fromHexString(
611: Long
612: .toHexString(l))
613: .toSubIndex(true);
614: }
615:
616: public Object mapToRowIdentifier(
617: OID rowIndex) {
618: if (rowIndex == null) {
619: return null;
620: }
621: OctetString os = new OctetString();
622: os.fromSubIndex(rowIndex,
623: true);
624: String hexString = os
625: .toHexString();
626: return new Long(Long
627: .parseLong(
628: hexString,
629: 16));
630: }
631: }));
632:
633: ObjectName onameJvmClasses = new ObjectName(
634: ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
635: ObjectName onameJvmRT = new ObjectName(
636: ManagementFactory.RUNTIME_MXBEAN_NAME);
637: ObjectName onameJitCompiler = new ObjectName(
638: ManagementFactory.COMPILATION_MXBEAN_NAME);
639: ObjectName onameJvmOS = new ObjectName(
640: ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
641: ObjectName onameJvmMemory = new ObjectName(
642: ManagementFactory.MEMORY_MXBEAN_NAME);
643:
644: scalarSupport.addAll(onameJvmClasses,
645: SCALAR_MBEANS_JVM_CLASSES);
646: scalarSupport.addAll(onameJvmRT, SCALAR_MBEANS_JVM_RUNTIME);
647: scalarSupport.addAll(onameJitCompiler,
648: SCALAR_MBEANS_JIT_COMPILER);
649: scalarSupport.addAll(onameJvmOS, SCALAR_MBEANS_JVM_OS);
650: scalarSupport.addAll(onameJvmMemory,
651: SCALAR_MBEANS_JVM_MEMORY);
652: scalarSupport.addAll(onameJvmThreading,
653: SCALAR_MBEANS_JVM_THREADING);
654:
655: scalarSupportActions.addAll(onameJvmMemory,
656: SCALAR_MBEANS_JVM_MEMORY_ACTIONS);
657:
658: tableSupport.add(super .oidJvmRTInputArgsEntry,
659: new MBeanAttributeListMOTableInfo(onameJvmRT,
660: new MBeanArrayIndexKeyProvider(onameJvmRT,
661: new TypedAttribute(
662: "InputArguments",
663: String[].class))));
664:
665: tableSupport.add(super .oidJvmRTBootClassPathEntry,
666: new MBeanAttributeListMOTableInfo(onameJvmRT,
667: new MBeanArrayIndexKeyProvider(onameJvmRT,
668: new SplitStringType(
669: "BootClassPath",
670: File.pathSeparator))));
671:
672: tableSupport.add(super .oidJvmRTClassPathEntry,
673: new MBeanAttributeListMOTableInfo(onameJvmRT,
674: new MBeanArrayIndexKeyProvider(onameJvmRT,
675: new SplitStringType("ClassPath",
676: File.pathSeparator))));
677:
678: tableSupport.add(super .oidJvmRTLibraryPathEntry,
679: new MBeanAttributeListMOTableInfo(onameJvmRT,
680: new MBeanArrayIndexKeyProvider(onameJvmRT,
681: new SplitStringType("LibraryPath",
682: File.pathSeparator))));
683:
684: } catch (NullPointerException ex) {
685: ex.printStackTrace();
686: } catch (MalformedObjectNameException ex) {
687: ex.printStackTrace();
688: }
689:
690: JMXTableModel jvmMemManagerEntryModel = new JMXTableModel(
691: super .oidJvmMemManagerEntry, tableSupport, super
692: .getJvmMemManagerEntry().getColumns());
693: ((MOTableJMX) super .getJvmMemManagerEntry())
694: .setModel(jvmMemManagerEntryModel);
695:
696: JMXTableModel jvmMemPoolEntryModel = new JMXTableModel(
697: super .oidJvmMemPoolEntry, tableSupport, super
698: .getJvmMemPoolEntry().getColumns());
699: ((MOTableJMX) super .getJvmMemPoolEntry())
700: .setModel(jvmMemPoolEntryModel);
701:
702: JMXTableModel jvmThreadInstanceEntryModel = new JMXTableModel(
703: super .oidJvmThreadInstanceEntry, tableSupport, super
704: .getJvmThreadInstanceEntry().getColumns());
705: ((MOTableJMX) super .getJvmThreadInstanceEntry())
706: .setModel(jvmThreadInstanceEntryModel);
707:
708: JMXTableModel jvmJvmRTInputArgsEntryModel = new JMXTableModel(
709: super .oidJvmRTInputArgsEntry, tableSupport, super
710: .getJvmRTInputArgsEntry().getColumns());
711: ((MOTableJMX) super .getJvmRTInputArgsEntry())
712: .setModel(jvmJvmRTInputArgsEntryModel);
713:
714: JMXTableModel jvmJvmRTBootClassPathEntryModel = new JMXTableModel(
715: super .oidJvmRTBootClassPathEntry, tableSupport, super
716: .getJvmRTBootClassPathEntry().getColumns());
717: ((MOTableJMX) super .getJvmRTBootClassPathEntry())
718: .setModel(jvmJvmRTBootClassPathEntryModel);
719:
720: JMXTableModel jvmJvmRTClassPathEntryModel = new JMXTableModel(
721: super .oidJvmRTClassPathEntry, tableSupport, super
722: .getJvmRTClassPathEntry().getColumns());
723: ((MOTableJMX) super .getJvmRTClassPathEntry())
724: .setModel(jvmJvmRTClassPathEntryModel);
725:
726: JMXTableModel jvmJvmRTLibraryPathEntryModel = new JMXTableModel(
727: super .oidJvmRTLibraryPathEntry, tableSupport, super
728: .getJvmRTLibraryPathEntry().getColumns());
729: ((MOTableJMX) super .getJvmRTLibraryPathEntry())
730: .setModel(jvmJvmRTLibraryPathEntryModel);
731:
732: }
733:
734: private void addJvmManagementMibConstraints(DefaultMOServer server) {
735: MOScalar scalar = (MOScalar) server
736: .getManagedObject(
737: JvmManagementMib.oidJvmThreadContentionMonitoring,
738: null);
739: ValueConstraint jvmThreadContentionMonitoringVC = new EnumerationConstraint(
740: new int[] {
741: JvmManagementMib.JvmThreadContentionMonitoringEnum.enabled,
742: JvmManagementMib.JvmThreadContentionMonitoringEnum.disabled });
743: scalar
744: .addMOValueValidationListener(new ValueConstraintValidator(
745: jvmThreadContentionMonitoringVC));
746: scalar = (MOScalar) server.getManagedObject(
747: JvmManagementMib.oidJvmThreadCpuTimeMonitoring, null);
748: ValueConstraint jvmThreadCpuTimeMonitoringVC = new EnumerationConstraint(
749: new int[] {
750: JvmManagementMib.JvmThreadContentionMonitoringEnum.enabled,
751: JvmManagementMib.JvmThreadContentionMonitoringEnum.disabled });
752: scalar
753: .addMOValueValidationListener(new ValueConstraintValidator(
754: jvmThreadCpuTimeMonitoringVC));
755: }
756:
757: }
|