Example usage for javax.management MBeanServerConnection queryNames

List of usage examples for javax.management MBeanServerConnection queryNames

Introduction

In this page you can find the example usage for javax.management MBeanServerConnection queryNames.

Prototype

public Set<ObjectName> queryNames(ObjectName name, QueryExp query) throws IOException;

Source Link

Document

Gets the names of MBeans controlled by the MBean server.

Usage

From source file:org.apache.cassandra.tools.NodeProbe.java

public ThreadPoolProxyMBeanIterator(MBeanServerConnection mbeanServerConn)
        throws MalformedObjectNameException, NullPointerException, IOException {
    Set<ObjectName> requests = mbeanServerConn.queryNames(new ObjectName("org.apache.cassandra.request:type=*"),
            null);//from w w w . ja  v a 2s .  c o m
    Set<ObjectName> internal = mbeanServerConn
            .queryNames(new ObjectName("org.apache.cassandra.internal:type=*"), null);
    resIter = Iterables.concat(requests, internal).iterator();
    this.mbeanServerConn = mbeanServerConn;
}

From source file:org.helios.collector.jmx.connection.AbstractMBeanServerConnectionFactory.java

/**
 * Queries a set of MBean ObjectNames from the passed ObjectName and Query expression
 * @param objectName//from ww w.  ja v  a  2 s.  c om
 * @param query
 * @return
 * @throws IOException
 */
@Override
@ManagedOperation
public Set<ObjectName> queryNames(ObjectName objectName, QueryExp query) throws IOException {
    validateConn();
    MBeanServerConnection conn = null;
    try {
        conn = getPooledConnection();
        return conn.queryNames(objectName, query);
    } catch (MBeanServerConnectionFactoryException e) {
        throw new RuntimeException("Failed to get pooled connection", e);
    } finally {
        try {
            this.returnPooledConnection(conn);
        } catch (Exception e) {
            log.debug(e.getMessage());
        }
    }
}

From source file:org.hyperic.hq.product.jmx.MxServerDetector.java

public Set discoverServiceTypes(ConfigResponse serverConfig) throws PluginException {
    JMXConnector connector = null;
    MBeanServerConnection mServer;
    Set serviceTypes = new HashSet();

    //plugins need to define these properties at the plugin level to discover dynamic service types
    if (getProductPlugin().getPluginData().getProperty(MEASUREMENT_CLASS_PROPERTY) == null
            || getProductPlugin().getPluginData().getProperty(CONTROL_CLASS_PROPERTY) == null
            || getProductPlugin().getPluginData().getProperty(TEMPLATE_PROPERTY) == null) {
        return serviceTypes;
    }/* w w  w.j  a v a  2s  .c  o  m*/

    try {
        connector = MxUtil.getCachedMBeanConnector(serverConfig.toProperties());
        mServer = connector.getMBeanServerConnection();
    } catch (Exception e) {
        MxUtil.close(connector);
        throw new PluginException(e.getMessage(), e);
    }

    try {
        final Set objectNames = mServer.queryNames(new ObjectName(MBeanUtil.DYNAMIC_SERVICE_DOMAIN + ":*"),
                null);
        serviceTypes = serviceTypeFactory.create(getProductPlugin(), (ServerTypeInfo) getTypeInfo(), mServer,
                objectNames);
    } catch (Exception e) {
        throw new PluginException(e.getMessage(), e);
    } finally {
        MxUtil.close(connector);
    }
    return serviceTypes;
}

From source file:org.apache.cassandra.tools.NodeProbe.java

private List<Entry<String, ColumnFamilyStoreMBean>> getCFSMBeans(MBeanServerConnection mbeanServerConn,
        String type) throws MalformedObjectNameException, IOException {
    ObjectName query = new ObjectName("org.apache.cassandra.db:type=" + type + ",*");
    Set<ObjectName> cfObjects = mbeanServerConn.queryNames(query, null);
    List<Entry<String, ColumnFamilyStoreMBean>> mbeans = new ArrayList<Entry<String, ColumnFamilyStoreMBean>>(
            cfObjects.size());//from www  .  j  a v a 2  s .  c om
    for (ObjectName n : cfObjects) {
        String keyspaceName = n.getKeyProperty("keyspace");
        ColumnFamilyStoreMBean cfsProxy = JMX.newMBeanProxy(mbeanServerConn, n, ColumnFamilyStoreMBean.class);
        mbeans.add(
                new AbstractMap.SimpleImmutableEntry<String, ColumnFamilyStoreMBean>(keyspaceName, cfsProxy));
    }
    return mbeans;
}

From source file:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java

private void registerPulseUrlToManager(JMXConnector connection)
        throws IOException, AttributeNotFoundException, InstanceNotFoundException, MBeanException,
        ReflectionException, MalformedObjectNameException, InvalidAttributeValueException {
    if (LOGGER.infoEnabled()) {
        LOGGER.info(resourceBundle.getString("LOG_MSG_REGISTERING_APP_URL_TO_MANAGER"));
    }//  w  ww  .j  a  va  2 s .  c  o  m

    // Reference to repository
    Repository repository = Repository.get();

    // Register Pulse URL if not already present in the JMX Manager
    if (connection != null) {
        MBeanServerConnection mbsc = connection.getMBeanServerConnection();

        Set<ObjectName> mbeans = mbsc.queryNames(this.MBEAN_OBJECT_NAME_MEMBER_MANAGER, null);

        for (ObjectName mbeanName : mbeans) {
            String presentUrl = (String) mbsc.getAttribute(mbeanName,
                    PulseConstants.MBEAN_MANAGER_ATTRIBUTE_PULSEURL);
            String pulseWebAppUrl = repository.getPulseWebAppUrl();
            if (pulseWebAppUrl != null && (presentUrl == null || !pulseWebAppUrl.equals(presentUrl))) {
                if (LOGGER.fineEnabled()) {
                    LOGGER.fine(resourceBundle.getString("LOG_MSG_SETTING_APP_URL_TO_MANAGER"));
                }
                Attribute pulseUrlAttr = new Attribute(PulseConstants.MBEAN_MANAGER_ATTRIBUTE_PULSEURL,
                        pulseWebAppUrl);
                mbsc.setAttribute(mbeanName, pulseUrlAttr);
            } else {
                if (LOGGER.fineEnabled()) {
                    LOGGER.fine(resourceBundle.getString("LOG_MSG_APP_URL_ALREADY_PRESENT_IN_MANAGER"));
                }
            }
        }
    }
}