private HostAndPort parseHostPort(Cluster cluster, String propertyName, String configType) throws MalformedURLException {
    String propertyValue = m_configHelper.getValueFromDesiredConfigurations(cluster, configType, propertyName);
    HostAndPort hp = HTTPUtils.getHostAndPortFromProperty(propertyValue);
    if (hp == null) {
      throw new MalformedURLException("Could not parse host and port from " + propertyValue);
    }
    return hp;
  }
Find the master and secondary namenode(s) based on JMX NameNodeStatus.
ambari-server/src/main/java/org/apache/ambari/server/stack/MasterHostResolver.java