private String[] getNamenodeHaProperty(Map<String, Object> properties, String pattern[],
    String hostName, String publicHostName) {

    // iterate over nameservices and namenodes, to find out namenode http(s) property for concrete host
    for(String nameserviceId : ((String)properties.get("dfs.internal.nameservices")).split(",")) {
      if(properties.containsKey("dfs.ha.namenodes."+nameserviceId)) {
        for (String namenodeId : ((String)properties.get("dfs.ha.namenodes." + nameserviceId)).split(",")) {
          String propertyName = String.format(
            pattern[0],
            nameserviceId,
            namenodeId
          );
          if (properties.containsKey(propertyName)) {
            String propertyValue = (String)properties.get(propertyName);
            String propHostName = propertyValue.split(":")[0];
            if (propHostName.equals(hostName) || propHostName.equals(publicHostName)) {
              return new String[] {propertyName};
            }
          }
        }
      }
    }
    return pattern;
  }
Computes properties that contains proper port for {@code componentName} on {@code hostName}.
Must contain custom logic for different configurations(like NAMENODE HA).
@param service service type
@param componentName component name
@param hostName host which contains requested component
@param properties properties which used for special cases(like NAMENODE HA)
@param httpsEnabled indicates if https enabled for component
@return property name that contain port for {@code componentName} on {@code hostName}
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java