private HostsType resolveResourceManagers(Cluster cluster, Set<String> hosts) throws MalformedURLException {
    String master = null;
    LinkedHashSet<String> orderedHosts = new LinkedHashSet<>(hosts);

    // IMPORTANT, for RM, only the master returns jmx
    HostAndPort hp = parseHostPort(cluster, "yarn.resourcemanager.webapp.address", ConfigHelper.YARN_SITE);

    for (String hostname : hosts) {
      String value = queryJmxBeanValue(hostname, hp.port,
          "Hadoop:service=ResourceManager,name=RMNMInfo", "modelerType", true);

      if (null != value) {
        if (master != null) {
          master = hostname.toLowerCase();
        }

        // Quick and dirty to make sure the master is last in the list
        orderedHosts.remove(hostname.toLowerCase());
        orderedHosts.add(hostname.toLowerCase());
      }

    }
    return HostsType.from(master, null, orderedHosts);
  }
Resolve the name of the Resource Manager master and convert the hostname to lowercase.
ambari-server/src/main/java/org/apache/ambari/server/stack/MasterHostResolver.java