Examples of ObjectNameQueryUtility


Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

        }
    }

    @Nullable
    private String getPartitionName() {
        ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(
            DISTRIBUTED_REPLICANT_MANAGER_MBEAN_NAME_TEMPLATE);
        try {
            List<EmsBean> mBeans = loadConnection().queryBeans(queryUtility.getTranslatedQuery());
            if (mBeans.size() == 1) {
                if (queryUtility.setMatchedKeyValues(mBeans.get(0).getBeanName().getKeyProperties())) {
                    return queryUtility.getVariableValues().get("partitionName");
                }
            }
        } catch (Exception e) {
            log.error("Could not load partition name as connection could not be loaded");
        }
View Full Code Here

Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

        Set<DiscoveredResourceDetails> services = new HashSet<DiscoveredResourceDetails>();
        String templates[] = objectNameQueryTemplateOrig.split("\\|");
        for (String objectNameQueryTemplate : templates) {
            // Get the query template, replacing the parent key variables with the values from the parent configuration
            ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(objectNameQueryTemplate,
                (this.discoveryContext != null) ? this.discoveryContext.getParentResourceContext()
                    .getPluginConfiguration() : null);

            List<EmsBean> beans = connection.queryBeans(queryUtility.getTranslatedQuery());
            if (log.isDebugEnabled()) {
                log.debug("Found [" + beans.size() + "] mbeans for query [" + queryUtility.getTranslatedQuery() + "].");
            }
            for (EmsBean bean : beans) {
                if (queryUtility.setMatchedKeyValues(bean.getBeanName().getKeyProperties())) {
                    // Only use beans that have all the properties we've made variables of

                    // Don't match beans that have unexpected properties
                    if (skipUnknownProps
                        && queryUtility.isContainsExtraKeyProperties(bean.getBeanName().getKeyProperties().keySet())) {
                        continue;
                    }

                    String resourceKey = bean.getBeanName().getCanonicalName(); // The detected object name

                    String nameTemplate = (pluginConfiguration.getSimple(PROPERTY_NAME_TEMPLATE) != null) ? pluginConfiguration
                        .getSimple(PROPERTY_NAME_TEMPLATE).getStringValue() : null;

                    String descriptionTemplate = (pluginConfiguration.getSimple(PROPERTY_DESCRIPTION_TEMPLATE) != null) ? pluginConfiguration
                        .getSimple(PROPERTY_DESCRIPTION_TEMPLATE).getStringValue() : null;

                    String name = resourceKey;
                    if (nameTemplate != null) {
                        name = queryUtility.formatMessage(nameTemplate);
                    }

                    String description = null;
                    if (descriptionTemplate != null) {
                        description = queryUtility.formatMessage(descriptionTemplate);
                    }

                    DiscoveredResourceDetails service = new DiscoveredResourceDetails(resourceType, resourceKey, name,
                        "", description, null, null);
                    Configuration config = service.getPluginConfiguration();
                    config.put(new PropertySimple(PROPERTY_OBJECT_NAME, bean.getBeanName().toString()));

                    Map<String, String> mappedVariableValues = queryUtility.getVariableValues();
                    for (String key : mappedVariableValues.keySet()) {
                        config.put(new PropertySimple(key, mappedVariableValues.get(key)));
                    }

                    services.add(service);

                    // Clear out the variables for the next bean detected
                    queryUtility.resetVariables();
                }
            }

            if (log.isDebugEnabled()) {
                log.debug("[" + services.size() + "] services have been added");
View Full Code Here

Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

     * @return the list of VHost MBeans for this webapp
     */
    public static List<EmsBean> getVHostsFromLocalManager(String contextRoot, EmsConnection emsConnection) {
        String contextPath = WarDiscoveryHelper.getContextPath(contextRoot);
        String pattern = "jboss.web:host=%host%,path=" + contextPath + ",type=Manager";
        ObjectNameQueryUtility queryUtil = new ObjectNameQueryUtility(pattern);
        List<EmsBean> managerMBeans = emsConnection.queryBeans(queryUtil.getTranslatedQuery());
        return managerMBeans;
    }
View Full Code Here

Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

     */
    public static List<EmsBean> getVHostsFromClusterManager(String contextRoot, EmsConnection emsConnection) {
        String contextPath = WarDiscoveryHelper.getContextPath(contextRoot);
        //String webModule = "//" + contextInfo.vhost + contextPath;
        String pattern = "jboss.web:service=ClusterManager,WebModule=%webModule%";
        ObjectNameQueryUtility queryUtil = new ObjectNameQueryUtility(pattern);
        List<EmsBean> clusterManagerMBeans = emsConnection.queryBeans(queryUtil.getTranslatedQuery());
        return clusterManagerMBeans;
    }
View Full Code Here

Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

        EmsConnection jmxConnection = getEmsConnection();
        String servletMBeanNames = SESSION_NAME_BASE_TEMPLATE.replace("%PATH%",
            WarDiscoveryHelper.getContextPath(this.contextRoot));
        servletMBeanNames = servletMBeanNames.replace("%HOST%", vhost);
        ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(servletMBeanNames);
        List<EmsBean> mBeans = jmxConnection.queryBeans(queryUtility.getTranslatedQuery());

        if (mBeans.size() == 0) {
            // retry with the cluster manager TODO select the local vs cluster mode on discovery
            servletMBeanNames = CLUSTER_SESSION_NAME_BASE_TEMPLATE.replace("%PATH%",
                WarDiscoveryHelper.getContextPath(this.contextRoot));
            servletMBeanNames = servletMBeanNames.replace("%HOST%", vhost);
            queryUtility = new ObjectNameQueryUtility(servletMBeanNames);
            mBeans = jmxConnection.queryBeans(queryUtility.getTranslatedQuery());
            if (mBeans.size() > 0)
                isClustered = true;
        }

        String property = metricName.substring(SESSION_PREFIX.length());
View Full Code Here

Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

    }

    private Double getServletMetric(String metricName) {
        String servletMBeanNames = SERVLET_NAME_BASE_TEMPLATE + ",WebModule=//" + this.vhost
            + WarDiscoveryHelper.getContextPath(this.contextRoot);
        ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(servletMBeanNames);
        List<EmsBean> mBeans = getEmsConnection().queryBeans(queryUtility.getTranslatedQuery());

        long min = Long.MAX_VALUE;
        long max = 0;
        long processingTime = 0;
        int requestCount = 0;
View Full Code Here

Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

     */
    @Nullable
    private EmsBean getJBossWebMBean() {
        String jbossWebMBeanName = getJBossWebMBeanName();
        if (jbossWebMBeanName != null) {
            ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(jbossWebMBeanName);
            List<EmsBean> mBeans = getEmsConnection().queryBeans(queryUtility.getTranslatedQuery());
            // There should only be one mBean for this match.
            if (mBeans.size() == 1) {
                return mBeans.get(0);
            }
        } else {
View Full Code Here

Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

        /*
         * Lookup all jboss.web:type=GlobalRequestProcessor,* MBeans in order to associate them later with the
         * corresponding jboss.web:type=Connector,* primary connector MBeans.
         */
        EmsConnection connection = context.getParentResourceComponent().getEmsConnection();
        ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(
            "jboss.web:type=GlobalRequestProcessor,name=%name%");
        List<EmsBean> beans = connection.queryBeans(queryUtility.getTranslatedQuery());

        // We can't populate the name and scheme in the plugin config if the GlobalRequestProcessor MBeans aren't
        // deployed yet, so just abort and try again the next time the PC calls us.
        if (beans.size() != resourceDetails.size()) {
            if (log.isDebugEnabled())
View Full Code Here

Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

   }

   private EmsBean queryBean(EmsConnection conn, String componentName) {
      String pattern = getSingleComponentPattern(cacheManagerName, cacheName, componentName);
      if (log.isTraceEnabled()) log.trace("Pattern to query is " + pattern);
      ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(pattern);
      List<EmsBean> beans = conn.queryBeans(queryUtility.getTranslatedQuery());
      for (EmsBean bean : beans) {
         if (isCacheComponent(bean, componentName)) {
            return bean;
         } else {
            log.warn(String.format("MBeanServer returned spurious object %s", bean.getBeanName().getCanonicalName()));
View Full Code Here

Examples of org.rhq.plugins.jmx.util.ObjectNameQueryUtility

      EmsConnection conn = parentComponent.getEmsConnection();
      if (conn != null) {
         if (trace) log.trace("Connection to ems server established: " + conn);

         // Run query for manager_object
         ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(objectName);
         List<EmsBean> beans = conn.queryBeans(queryUtility.getTranslatedQuery());
         if (trace) log.trace("Querying ["+queryUtility.getTranslatedQuery()+"] returned beans: " + beans);

         Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
         for (EmsBean bean : beans) {
            // Filter out spurious beans
            if (CacheManagerComponent.isCacheManagerComponent(bean)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.