private HostsType resolveHBaseMasters(Cluster cluster, Set<String> hosts) throws AmbariException {
    String master = null;
    String secondary = null;
    String hbaseMasterInfoPortProperty = "hbase.master.info.port";
    String hbaseMasterInfoPortValue = m_configHelper.getValueFromDesiredConfigurations(cluster, ConfigHelper.HBASE_SITE, hbaseMasterInfoPortProperty);

    if (hbaseMasterInfoPortValue == null || hbaseMasterInfoPortValue.isEmpty()) {
      throw new AmbariException("Could not find property " + hbaseMasterInfoPortProperty);
    }

    final int hbaseMasterInfoPort = Integer.parseInt(hbaseMasterInfoPortValue);
    for (String hostname : hosts) {
      String value = queryJmxBeanValue(hostname, hbaseMasterInfoPort,
          "Hadoop:service=HBase,name=Master,sub=Server", "tag.isActiveMaster", false);

      if (null != value) {
        Boolean bool = Boolean.valueOf(value);
        if (bool.booleanValue()) {
          master = hostname.toLowerCase();
        } else {
          secondary = hostname.toLowerCase();
        }
      }
    }
    return HostsType.from(master, secondary, new LinkedHashSet<>(hosts));
  }
Resolve the HBASE master and convert the hostname to lowercase.
ambari-server/src/main/java/org/apache/ambari/server/stack/MasterHostResolver.java