public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) { try { return delegate.queryMBeans(name, query); } catch(IOException e) { throw new RuntimeException(e); } }
private void mappingCollctors() throws Exception { Set<ObjectInstance> beans = mbsc.queryMBeans(Client.getObjectName(GARBAGE_COLLECTORS), null); for (ObjectInstance collector : beans) { ObjectName collectorObjName = collector.getObjectName(); String collectorName = getAttribute(collectorObjName, "Name"); if ("Copy".equals(collectorName) || "PS Scavenge".equals(collectorName) || "ParNew".equals(collectorName) || "G1 Young Generation".equals(collectorName)) { ygcCollector = collectorObjName; } else if ("MarkSweepCompact".equals(collectorName) || "PS MarkSweep".equals(collectorName) || "ConcurrentMarkSweep".equals(collectorName) || "G1 Old Generation".equals(collectorName)) { fgcCollector = collectorObjName; } else { ygcCollector = collectorObjName; } } }
private void mappingPools() throws Exception { Set<ObjectInstance> beans = mbsc.queryMBeans(Client.getObjectName(MEM_POOL_PREFIX + "*"), null); for (ObjectInstance pool : beans) { ObjectName poolObjName = pool.getObjectName(); String poolName = getAttribute(poolObjName, "Name"); poolName = poolName.trim().toLowerCase(); if (poolName.contains("eden")) { eden = poolObjName; } else if (poolName.contains("survivor")) { sur = poolObjName; } else if (poolName.contains("old") || poolName.contains("tenured")) { old = poolObjName; } else if (poolName.contains("perm") || poolName.contains("metaspace")) { perm = poolObjName; } else if (poolName.contains("compressed class space")) { ccs = poolObjName; } } }
Map<String,String[]> env = new HashMap<String, String[]>(); env.put( JMXConnector.CREDENTIALS, new String[]{"user","pass"} ); JMXServiceURL address = new JMXServiceURL("service:rmi:///jndi/rmi://host:port/jmxrmi"); JMXConnector connector = JMXConnectorFactory.connect(address,env); MBeanServerConnection mbs = connector.getMBeanServerConnection(); //get all mbeans Set<ObjectInstance> beans = mbs.queryMBeans(null,null); for( ObjectInstance instance : beans ) { MBeanInfo info = mbs.getMBeanInfo( instance.getObjectName() ); }
protected static Object[] doBeans(final MBeanServerConnection mbsc, final ObjectName objName, final String[] command, final boolean oneBeanOnly) throws Exception { Object[] result = null; Set beans = mbsc.queryMBeans(objName, null); if (beans.isEmpty()) {
private ObjectName getObjectName(Class<?> proxyClass, String beanQueryName) throws MalformedObjectNameException, IOException { ObjectName name = null; QueryExp query = null; if (proxyClass != null) { query = Query.isInstanceOf(Query.value(proxyClass.getName())); } if (beanQueryName != null) { name = ObjectName.getInstance(beanQueryName); } Set<ObjectInstance> beans = con.queryMBeans(name, query); assertEquals("failed to find only one instance of type " + proxyClass.getName() + " with name " + beanQueryName, 1, beans.size()); return ((ObjectInstance) beans.toArray()[0]).getObjectName(); }
params[ 0 ] = payloadObject; System.err.println("Querying MBeans"); Set<ObjectInstance> testMBeans = mbc.queryMBeans(null, null); System.err.println("Found " + testMBeans.size() + " MBeans"); for ( ObjectInstance oi : testMBeans ) {
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("QueryMBeans"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); } ObjectName objectName; QueryExp query; try { Unmarshaller unmarshaller = prepareForUnMarshalling(input); objectName = unmarshaller.readObject(ObjectName.class); paramType = unmarshaller.readByte(); if (paramType != QUERY_EXP) { throw new IOException("Unexpected paramType"); } query = unmarshaller.readObject(QueryExp.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } Set<ObjectInstance> instances = server.getMBeanServerConnection().queryMBeans(objectName, query); writeResponse(instances, SET_OBJECT_INSTANCE, QUERY_MBEANS, correlationId); log.tracef("[%d] QueryMBeans - Success Response Sent", correlationId); } }
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("QueryMBeans"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); } ObjectName objectName; QueryExp query; try { Unmarshaller unmarshaller = prepareForUnMarshalling(input); objectName = unmarshaller.readObject(ObjectName.class); paramType = unmarshaller.readByte(); if (paramType != QUERY_EXP) { throw new IOException("Unexpected paramType"); } query = unmarshaller.readObject(QueryExp.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } Set<ObjectInstance> instances = server.getMBeanServerConnection().queryMBeans(objectName, query); writeResponse(instances, SET_OBJECT_INSTANCE, QUERY_MBEANS, correlationId); log.tracef("[%d] QueryMBeans - Success Response Sent", correlationId); } }
LOG.warn("Failed to get bean!!! " + target, e); if (mb != null) { Set<ObjectInstance> instances = mb.queryMBeans(null, null); Iterator<ObjectInstance> iterator = instances.iterator(); System.out.println("MBean Found:");
LOG.warn("Failed to get bean." + target, e); if (mb != null) { Set<ObjectInstance> instances = mb.queryMBeans(null, null); Iterator<ObjectInstance> iterator = instances.iterator(); LOG.warn("MBean Found:");
protected Collection<ObjectName> retrieveMBeanNames() { List<ObjectName> objectNames = new ArrayList<ObjectName>(); for (ObjectName pattern : this.mBeanObjectNames) { Set<ObjectInstance> mBeanInfos; try { mBeanInfos = this.server.queryMBeans(pattern, null); } catch (IOException e) { throw new IllegalStateException("IOException on MBeanServerConnection.", e); } if (mBeanInfos.size() == 0 && this.logger.isDebugEnabled()) { this.logger.debug("No MBeans found matching pattern:" + pattern); } for (ObjectInstance instance : mBeanInfos) { if (this.logger.isDebugEnabled()) { this.logger.debug("Found MBean:" + instance.getObjectName().toString()); } objectNames.add(instance.getObjectName()); } } return objectNames; }
/** * Provides the mapped tree object */ @Override protected Object doReceive() { Assert.notNull(this.server, "MBeanServer is required"); try { Map<String, Object> beans = new HashMap<String, Object>(); Set<ObjectInstance> results = this.server.queryMBeans(this.queryName, this.queryExpression); for (ObjectInstance instance : results) { Object result = this.converter.convert(this.server, instance); beans.put(instance.getObjectName().getCanonicalName(), result); } return beans; } catch (Exception e) { throw new MessagingException("Failed to retrieve tree snapshot", e); } }
for (ObjectInstance instance : beanConn.queryMBeans(name, null)) { mBeanNames.add(instance.getObjectName()); for (ObjectInstance instance : beanConn.queryMBeans(name, null)) { mBeanNames.remove(instance.getObjectName());
@Override public Set<ObjectInstance> call() throws Exception { return getConnectionOrFail().queryMBeans(objectName, null); }}); }
public Set<ObjectInstance> queryMBeans(ObjectName objectName,QueryExp queryExp) throws IOException { return this.jmxc.getMBeanServerConnection().queryMBeans(objectName, queryExp); }// -------------------------------------------------------- /**
@Override public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) throws IOException { try { return connection.queryMBeans(name, query); } catch (IOException e) { checkConnection(); return connection.queryMBeans(name, query); } }
//Get the connection MBeanServerConnection connection = org.jboss.mx.util.MBeanServerLocator.locateJBoss(); //Query for MBeans in the chap2.xmbean namespace Set<ObjectInstance> mbeans = connection.queryMBeans(null, new ObjectName("chap2.xmbean:service=*")); //Loop over each MBean and invoke an interface method for (ObjectInstance mbean : mbeans) { //Invoking 'put' method from example. If this were an info method, this would return the result of the MBean operation connection .invoke(mbean.getObjectName(), "put", new Object[] {"TestKey", "TestValue"}, new String[] {Object.class.getName(), Object.class.getName()}); }
public static final Object findMBean(final ObjectName objectName, final Class mBeanInterface, final MBeanServerConnection mBeanServer) throws IOException { final Set matchingBeans = mBeanServer.queryMBeans(objectName, null); final Iterator beanPos = matchingBeans.iterator(); if (beanPos.hasNext()) { return MBeanServerInvocationHandler.newProxyInstance(mBeanServer, objectName, mBeanInterface, false); } return null; }
@Test public void testGetQueryMBeans() throws Exception { assertEquals(mbeanServerConnection.queryMBeans(testMBeanName, null), platformMBeanServer.queryMBeans(testMBeanName, null)); assertEquals(mbeanServerConnection.queryMBeans(new ObjectName("*:*"), null), platformMBeanServer.queryMBeans(new ObjectName("*:*"), null)); }