public static Map<String, String> createComponentHostMap(Collection<String> services, Function<String, Collection<String>> componentsLookup, BiFunction<String, String, Collection<String>> hostAssignmentLookup) {
    Map<String, String> componentHostsMap = new HashMap<>();
    for (String service : services) {
      Collection<String> components = componentsLookup.apply(service);
      for (String component : components) {
        Collection<String> hosts = hostAssignmentLookup.apply(service, component);
        componentHostsMap.put(getClusterHostInfoKey(component), StringUtils.join(hosts, ","));
      }
    }
    return componentHostsMap;
  }
Create a component -> hosts mapping that can be used for clusterHostInfo.
Component names are transformed to clusterHostInfo keys ("_hosts" is appended).
List of hosts is comma-separated.

@param services collection of services to create the mapping for
@param componentsLookup function to find components of a given service
@param hostAssignmentLookup function to find hosts of a given (service, component) pair
@return component names
ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java