Package javax.management

Examples of javax.management.Attribute


        name = new ObjectName("org.h2:name=JMX,path=mem_jmx");
        info = mbeanServer.getMBeanInfo(name);
        assertEquals("0", mbeanServer.getAttribute(name, "CacheSizeMax").toString());
        // cache size is ignored for in-memory databases
        mbeanServer.setAttribute(name, new Attribute("CacheSizeMax", 1));
        assertEquals("0", mbeanServer.getAttribute(name, "CacheSizeMax").toString());
        assertEquals("0", mbeanServer.getAttribute(name, "CacheSize").toString());
        assertEquals("false", mbeanServer.getAttribute(name, "Exclusive").toString());
        assertEquals("0", mbeanServer.getAttribute(name, "FileSize").toString());
        assertEquals("0", mbeanServer.getAttribute(name, "FileReadCount").toString());
        assertEquals("0", mbeanServer.getAttribute(name, "FileWriteCount").toString());
        assertEquals("0", mbeanServer.getAttribute(name, "FileWriteCountTotal").toString());
        assertEquals("0", mbeanServer.getAttribute(name, "LogMode").toString());
        // ignored for in-memory databases
        mbeanServer.setAttribute(name, new Attribute("LogMode", 1));
        assertEquals("0", mbeanServer.getAttribute(name, "LogMode").toString());
        assertEquals("REGULAR", mbeanServer.getAttribute(name, "Mode").toString());
        assertEquals("false", mbeanServer.getAttribute(name, "MultiThreaded").toString());
        assertEquals("false", mbeanServer.getAttribute(name, "Mvcc").toString());
        assertEquals("false", mbeanServer.getAttribute(name, "ReadOnly").toString());
        assertEquals("1", mbeanServer.getAttribute(name, "TraceLevel").toString());
        mbeanServer.setAttribute(name, new Attribute("TraceLevel", 0));
        assertEquals("0", mbeanServer.getAttribute(name, "TraceLevel").toString());
        assertTrue(mbeanServer.getAttribute(name, "Version").toString().startsWith("1."));
        assertEquals(14, info.getAttributes().length);
        result = mbeanServer.invoke(name, "listSettings", null, null).toString();
        assertTrue(result.indexOf("ANALYZE_AUTO") >= 0);

        conn.setAutoCommit(false);
        stat.execute("create table test(id int)");
        stat.execute("insert into test values(1)");

        result = mbeanServer.invoke(name, "listSessions", null, null).toString();
        assertTrue(result.indexOf("session id") >= 0);
        assertTrue(result.indexOf("write lock") >= 0);

        assertEquals(2, info.getOperations().length);
        assertTrue(info.getDescription().indexOf("database") >= 0);
        attrMap = New.hashMap();
        for (MBeanAttributeInfo a : info.getAttributes()) {
            attrMap.put(a.getName(), a);
        }
        assertTrue(attrMap.get("CacheSize").getDescription().indexOf("KB") >= 0);
        opMap = New.hashMap();
        for (MBeanOperationInfo o : info.getOperations()) {
            opMap.put(o.getName(), o);
        }
        assertTrue(opMap.get("listSessions").getDescription().indexOf("lock") >= 0);
        assertEquals(MBeanOperationInfo.INFO, opMap.get("listSessions").getImpact());

        conn.close();

        conn = getConnection("jmx;jmx=true");

        name = new ObjectName("org.h2:name=JMX,*");
        Set set = mbeanServer.queryNames(name, null);
        name = (ObjectName) set.iterator().next();

        assertEquals("16384", mbeanServer.getAttribute(name, "CacheSizeMax").toString());
        mbeanServer.setAttribute(name, new Attribute("CacheSizeMax", 1));
        assertEquals("1", mbeanServer.getAttribute(name, "CacheSizeMax").toString());
        assertTrue(0 < (Integer) mbeanServer.getAttribute(name, "CacheSize"));
        assertTrue(0 < (Long) mbeanServer.getAttribute(name, "FileSize"));
        assertTrue(0 < (Long) mbeanServer.getAttribute(name, "FileReadCount"));
        assertTrue(0 < (Long) mbeanServer.getAttribute(name, "FileWriteCount"));
        assertTrue(0 < (Long) mbeanServer.getAttribute(name, "FileWriteCountTotal"));
        mbeanServer.setAttribute(name, new Attribute("LogMode", 0));
        assertEquals("0", mbeanServer.getAttribute(name, "LogMode").toString());

        conn.close();

    }
View Full Code Here


      e.printStackTrace();
    }
  }
  public void setLastResponseTime(String serviceName,Long arg){
    ObjectName objName = (ObjectName)objectNames.get(serviceName);
    Attribute attrib = new Attribute("LastResponseTime",arg);
    try {
      mbs.setAttribute(objName,attrib);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

            getInstrumentationAttributes(greeterInstrumentation);

            
            mbsc.setAttribute(greeterInstrumentation,
                              new Attribute("PingMeCounter", new Integer("20")));
            echo("\n >>> set the GreeterInstrumentation PingMeCounter to be 20 <<<");
            echo("\n >>> get the GreeterInstrumentation counter infor <<<");

            getInstrumentationAttributes(greeterInstrumentation);
                             
View Full Code Here

               returnObject = mbeanServer.getAttribute(objectName, action);
            }
            else if (action.startsWith("set")) {
               action = action.substring(3);
               Object value = (params.length>0) ? params[0] : "";
               Attribute attribute = new Attribute(action, value);
               if (log.isLoggable(Level.FINE)) log.fine("invoke: '" + attribute.toString() + "@" + objectName);
               mbeanServer.setAttribute(objectName, attribute);
               returnObject = "";
            }
            else {
               if (log.isLoggable(Level.FINE)) log.fine("invoke: '" + action + "@" + objectName);
View Full Code Here

                                info.getDescription());
    }

   
    public void testSetAttribute() throws Exception {       
        getServer().setAttribute(ton, new Attribute(AGE_ATTRIBUTE, 12));
        assertEquals("The Age should be ", 12, ati.getAge());
        getServer().setAttribute(ton, new Attribute(NAME_ATTRIBUTE, "Rob Harrop"));               
        assertEquals("The name should be ", "Rob Harrop", ati.getName());
    }
View Full Code Here

      }

      sc.install(on, loaderObjectName, element);

      // inject dependencies
      mbeanServer.setAttribute(on, new Attribute("ServerPeer", getServiceName()));
      mbeanServer.setAttribute(on, new Attribute("JNDIName", jndiName));
      if (params)
      {
         mbeanServer.setAttribute(on, new Attribute("FullSize", new Integer(fullSize)));
         mbeanServer.setAttribute(on, new Attribute("PageSize", new Integer(pageSize)));
         mbeanServer.setAttribute(on, new Attribute("DownCacheSize", new Integer(downCacheSize)));
      }
      mbeanServer.invoke(on, "create", new Object[0], new String[0]);
      mbeanServer.invoke(on, "start", new Object[0], new String[0]);

      return (String)mbeanServer.getAttribute(on, "JNDIName");
View Full Code Here

    */
   public void setAttribute(ObjectName on, String name, String valueAsString) throws Exception
   {
      MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(on);
      Object value = type(mbeanInfo, name, valueAsString);
      mbeanServer.setAttribute(on, new Attribute(name, value));
   }
View Full Code Here

      // register it
      mbeanServer.registerMBean(cfBindingService, on);

      // configure it
      mbeanServer.setAttribute(on, new Attribute("ConnectionManager", JMS_CONNECTION_MANAGER_OBJECT_NAME));
      mbeanServer.setAttribute(on, new Attribute("JndiName", JCA_JMS_CONNECTION_FACTORY_JNDI_NAME));
      mbeanServer.setAttribute(on, new Attribute("UseJavaContext", Boolean.TRUE));

      // start it
      mbeanServer.invoke(on, "start", new Object[0], new String[0]);

      log.debug("started " + on);
View Full Code Here

     
      ObjectName postOfficeObjectName = new ObjectName("jboss.messaging:service=PostOffice");

      mBeanServer.invoke(postOfficeObjectName, "stop", null, null);
     
      Attribute att =
         new Attribute("MessagePullPolicy",
                       "org.jboss.messaging.core.plugin.postoffice.cluster.NullMessagePullPolicy");
     
      mBeanServer.setAttribute(postOfficeObjectName, att);

      // Restart the post office
View Full Code Here

   }

   public void selfTest() throws Exception
   {
      CustomType ct = new CustomType(666, 999);
      getServer().setAttribute(getServiceName(), new Attribute("Attr", ct));
   }
View Full Code Here

TOP

Related Classes of javax.management.Attribute

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.