Package org.snmp4j.agent.mo.jmx.util

Examples of org.snmp4j.agent.mo.jmx.util.AbstractSyntheticJMXIndexSupport


    try {
      ObjectName onameJvmMemManagerEntry =
          new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE+
                         ",*");

      final AbstractSyntheticJMXIndexSupport jvmMemManagerIndexSupport =
          new AbstractSyntheticJMXIndexSupport() {
          public ObjectName mapToRowMBean(Object rowIdentifier) {
            try {
              return new ObjectName(ManagementFactory.
                                    MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE +
                                    ",name=" + rowIdentifier);
            }
            catch (Exception ex) {
              ex.printStackTrace();
              return null;
            }
          }
      };

      tableSupport.add(super.oidJvmMemManagerEntry,
          new MBeanAttributeMOTableInfo(onameJvmMemManagerEntry,
                                        null,
                                        new TypedAttribute[] {
                                        new TypedAttribute("Name", String.class),
                                        new InverseBooleanType("Valid")},
                                        new String[] { "Name" },
                                        jvmMemManagerIndexSupport));

      ObjectName onameJvmMem =
         new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
      notificationSupport.add(JvmManagementMib.oidJvmLowMemoryPoolUsageNotif,
                              new MBeanNotificationInfo(jvmLowMemoryPoolUsageNotif,
          new JMXAttributeNotificationIndexSupport(
          new TypedAttribute("poolName", String.class),
          jvmMemManagerIndexSupport)));
      try {
        server.addNotificationListener(onameJvmMem,
                                       notificationSupport, null,
                                       JvmManagementMib.
                                       oidJvmLowMemoryPoolUsageNotif);
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
      notificationSupport.add(JvmManagementMib.oidJvmLowMemoryPoolCollectNotif,
                              new MBeanNotificationInfo(jvmLowMemoryPoolCollectNotif,
          new JMXAttributeNotificationIndexSupport(
          new TypedAttribute("poolName", String.class),
          jvmMemManagerIndexSupport)));
      try {
        server.addNotificationListener(onameJvmMem,
                                       notificationSupport, null,
                                       JvmManagementMib.
                                       oidJvmLowMemoryPoolCollectNotif);
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }

      ObjectName onameJvmMemPoolEntry =
          new ObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE+",*");

      final AbstractSyntheticJMXIndexSupport jvmMemPoolIndexSupport =
          new AbstractSyntheticJMXIndexSupport() {
        public ObjectName mapToRowMBean(Object rowIdentifier) {
          try {
            return new ObjectName(ManagementFactory.
                                  MEMORY_POOL_MXBEAN_DOMAIN_TYPE +
                                  ",name=" + rowIdentifier);
          }
          catch (Exception ex) {
            ex.printStackTrace();
            return null;
          }
        }
      };

      tableSupport.add(super.oidJvmMemPoolEntry,
          new MBeanAttributeMOTableInfo(onameJvmMemPoolEntry,
          null,
          new TypedAttribute[] {
            new TypedAttribute("Name", String.class),
            new EnumStringType("Type", MemoryType.class, MemoryType.values() ),
            new InverseBooleanType("Valid"),
            new TimeAction("Name","resetPeakUsage", server),
            new TypedCompositeDataAttribute("Usage", "init", Long.class),
            new TypedCompositeDataAttribute("Usage", "used", Long.class),
            new TypedCompositeDataAttribute("Usage", "committed", Long.class),
            new TypedCompositeDataAttribute("Usage", "max", Long.class),
            new TypedCompositeDataAttribute("PeakUsage", "used", Long.class),
            new TypedCompositeDataAttribute("PeakUsage", "committed", Long.class),
            new TypedCompositeDataAttribute("PeakUsage", "max", Long.class),
            new TypedCompositeDataAttribute("CollectionUsage", "used", Long.class),
            new TypedCompositeDataAttribute("CollectionUsage", "committed", Long.class),
            new TypedCompositeDataAttribute("CollectionUsage", "max", Long.class),
            new TypedAttribute("UsageThreshold", Long.class),
            new TypedAttribute("UsageThresholdCount", Long.class),
            new InverseBooleanType("UsageThresholdSupported"),
            new TypedAttribute("CollectionUsageThreshold", Long.class),
            new TypedAttribute("CollectionUsageThresholdCount", Long.class),
            new InverseBooleanType("CollectionUsageThresholdSupported")
          },
          new String[] { "Name" },
          jvmMemPoolIndexSupport));

      ObjectName onameJvmMemMgrPoolRelEntry =
          new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE+",*");

      MBeanInvokationKeyProvider jvmMemMgrPoolRelKeyProvider =
          new MBeanInvokationKeyProvider(new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE),
                                         new TypedAttribute("MemoryPoolNames", String.class),
                                         "getMemoryPoolNames", true);

      tableSupport.add(super.oidJvmMemMgrPoolRelEntry,
          new MBeanAttributeMOTableInfo(onameJvmMemMgrPoolRelEntry,
                                        new MBeanAttributeKeyProvider(onameJvmMemMgrPoolRelEntry,
                                        null, true, jvmMemMgrPoolRelKeyProvider,
                                        new String[] { "Name" })  {
  protected ObjectName getSubKeyProviderObjectName(Object key) throws
      MalformedObjectNameException {
    return new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE+
                          ",name="+key);
  }
},
          new TypedAttribute[] {
            new TypedAttribute("Name", String.class),
            new TypedAttribute("MemoryPoolName", String.class)
          },
          new String[] { "Name", "MemoryPoolName" },
          new JMXIndexSupport() {
        public ObjectName mapToRowMBean(Object rowIdentifier) {
          return null;
        }

        public Object getRowIdentifier(Object nativeRowId, int nativeIndex) {
          return nativeRowId;
        }

        public OID mapToIndex(Object rowIdentifier) {
          Object[] key = (Object[])rowIdentifier;
          OID index = new OID(jvmMemManagerIndexSupport.mapToIndex(key[0]));
          index.append(jvmMemPoolIndexSupport.mapToIndex(key[1]));
          return index;
        }

        public Object mapToRowIdentifier(OID rowIndex) {
          if (rowIndex == null) {
           return null;
         }
         Object[] rowIdentifier = new Object[2];
         rowIdentifier[0] =
             jvmMemManagerIndexSupport.mapToRowIdentifier(
          new OID(rowIndex.toIntArray(), 0, 1));
         rowIdentifier[1] =
             jvmMemPoolIndexSupport.mapToRowIdentifier(
          new OID(rowIndex.toIntArray(), 1, 1));
         return rowIdentifier;
        }
      }
      ));
View Full Code Here

TOP

Related Classes of org.snmp4j.agent.mo.jmx.util.AbstractSyntheticJMXIndexSupport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.