protected String queryJmxBeanValue(String hostname, int port, String beanName, String attributeName,
                                  boolean asQuery, boolean encrypted) {

    String protocol = encrypted ? "https://" : "http://";
    String endPoint = protocol + (asQuery ?
        String.format("%s:%s/jmx?qry=%s", hostname, port, beanName) :
        String.format("%s:%s/jmx?get=%s::%s", hostname, port, beanName, attributeName));

    String response = HTTPUtils.requestURL(endPoint);

    if (null == response || response.isEmpty()) {
      return null;
    }

    Type type = new TypeToken<Map<String, ArrayList<HashMap<String, String>>>>() {}.getType();

    try {
      Map<String, ArrayList<HashMap<String, String>>> jmxBeans =
          StageUtils.getGson().fromJson(response, type);

      return jmxBeans.get("beans").get(0).get(attributeName);
    } catch (Exception e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Could not load JMX from {}/{} from {}", beanName, attributeName, hostname, e);
      } else {
        LOG.debug("Could not load JMX from {}/{} from {}", beanName, attributeName, hostname);
      }
    }

    return null;
  }
Query the JMX attribute at http(s)://$server:$port/jmx?qry=$query or http(s)://$server:$port/jmx?get=$bean::$attribute
@param hostname host name
@param port port number
@param beanName if asQuery is false, then search for this bean name
@param attributeName if asQuery is false, then search for this attribute name
@param asQuery whether to search bean or query
@param encrypted true if using https instead of http.
@return The jmx value.
ambari-server/src/main/java/org/apache/ambari/server/stack/MasterHostResolver.java