Package javax.management

Examples of javax.management.ObjectName$Property


    public List getPools() throws Exception {

        List memoryPools = new LinkedList();
        MBeanServer mBeanServer = new Registry().getMBeanServer();
        Set memoryOPools = mBeanServer.queryMBeans(new ObjectName("java.lang:type=MemoryPool,*"), null);

        //
        // totals
        //
        long totalInit = 0;
        long totalMax = 0;
        long totalUsed = 0;
        long totalCommitted = 0;

        for (Iterator it = memoryOPools.iterator(); it.hasNext();) {
            ObjectInstance oi = (ObjectInstance) it.next();
            ObjectName oName = oi.getObjectName();
            MemoryPool memoryPool = new MemoryPool();
            memoryPool.setName(JmxTools.getStringAttr(mBeanServer, oName, "Name"));
            memoryPool.setType(JmxTools.getStringAttr(mBeanServer, oName, "Type"));

            CompositeDataSupport cd = (CompositeDataSupport) mBeanServer.getAttribute(oName, "Usage");
            //
            // It seems that "Usage" attribute of one of the pools may turn into null intermittently. We better have a
            // dip in the graph then an NPE though.
            //
            if (cd != null) {
                memoryPool.setMax(JmxTools.getLongAttr(cd, "max"));
                memoryPool.setUsed(JmxTools.getLongAttr(cd, "used"));
                memoryPool.setInit(JmxTools.getLongAttr(cd, "init"));
                memoryPool.setCommitted(JmxTools.getLongAttr(cd, "committed"));
            } else {
                logger.error("Oops, JVM problem? "+oName.toString()+" \"Usage\" attribute is NULL!");
            }

            totalInit += memoryPool.getInit();
            totalMax += memoryPool.getMax();
            totalUsed += memoryPool.getUsed();
View Full Code Here


      assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
   }

   public void testSetCacheObjectName() throws Exception
   {
      ObjectName on = new ObjectName("jboss.cache:test=SetCacheObjectName");
      boolean registered = false;
      try
      {
         CacheJmxWrapper<String, String> wrapper = createWrapper(createConfiguration());
         wrapper.setCacheObjectName(on.getCanonicalName());

         // Register under the standard name
         registerWrapper(wrapper);
         // Should be registered under 'on'
         registered = mBeanServer.isRegistered(on);

         assertTrue("Registered with configured name", registered);
         assertEquals("Configured name retained", on.getCanonicalName(), wrapper.getCacheObjectName());

         wrapper.create();
         wrapper.start();

         interceptorRegistrationTest(on.getCanonicalName(), true);

         wrapper.stop();
         wrapper.destroy();

         interceptorRegistrationTest(false);
View Full Code Here

      }
   }

   public void testGetCacheObjectName() throws Exception
   {
      ObjectName on = new ObjectName("jboss.cache:test=SetCacheObjectName");
      String str = on.getCanonicalName();
      CacheJmxWrapper<String, String> wrapper = createWrapper(createConfiguration());
      wrapper.setCacheObjectName(str);

      assertEquals("Setter and getter match", str, wrapper.getCacheObjectName());

      // Go back to the default
      wrapper.setCacheObjectName(null);
      assertEquals("Got default ObjectName", JmxRegistrationManager.REPLICATED_CACHE_PREFIX + clusterName, wrapper.getCacheObjectName());

      registerWrapper(wrapper);
      assertEquals("Returns standard name", mBeanName, new ObjectName(wrapper.getCacheObjectName()));
   }
View Full Code Here

      m_server = MBeanServerFactory.createMBeanServer();

      Object cacheMBean = createCacheAndJmxWrapper();

      //    bind manually for now.
      ObjectName mgmt = getWrapperObjectName();

      m_server.registerMBean(cacheMBean, mgmt);
   }
View Full Code Here

      destroyCache();

      if (m_server != null)
      {
         ObjectName mgmt = getWrapperObjectName();
         if (m_server.isRegistered(mgmt))
            m_server.unregisterMBean(mgmt);
      }
   }
View Full Code Here

      }
   }

   protected ObjectName getWrapperObjectName() throws Exception
   {
      return new ObjectName(JmxRegistrationManager.REPLICATED_CACHE_PREFIX + CLUSTER_NAME);
   }
View Full Code Here

   public void testNotifications() throws Exception
   {
      assertNotNull("MBeanServer is null.", m_server);
      assertNotNull("Cache is null.", cache);

      ObjectName mgmt = getWrapperObjectName();
      MyListener listener = new MyListener(mgmt);


      m_server.addNotificationListener(mgmt, listener, null, null);
View Full Code Here

   {
      // undo setup
      cleanup();

      CacheJmxWrapper<Object, Object> wrapper = new CacheJmxWrapper<Object, Object>();
      ObjectName mgmt = getWrapperObjectName();
      m_server.registerMBean(wrapper, mgmt);
      MyListener listener = new MyListener(mgmt);
      m_server.addNotificationListener(mgmt, listener, null, null);

      cache = createCache(CLUSTER_NAME);
View Full Code Here

      // start the cache before registering listener
      cache.start();

      try
      {
         ObjectName mgmt = getWrapperObjectName();
         MyListener listener = new MyListener(mgmt);

         m_server.addNotificationListener(mgmt, listener, null, null);

         // add a node - this will trigger NodeCreated, NodeModify(pre/post) and NodeModified
View Full Code Here

   public void testListenerRemoval() throws Exception
   {
      assertNotNull("MBeanServer is null.", m_server);
      assertNotNull("Cache is null.", cache);

      ObjectName mgmt = getWrapperObjectName();
      MyListener listener = new MyListener(mgmt);

      m_server.addNotificationListener(mgmt, listener, null, null);

      // start the cache after registering listener - this will trigger CacheStarted
View Full Code Here

TOP

Related Classes of javax.management.ObjectName$Property

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.