private Map<String, Set<String>> calculateHostGroupComponentsMap(Cluster cluster) {
    Map<String, Set<String>> map = new HashMap<>();
    List<Host> hosts = new ArrayList<>(cluster.getHosts());
    if (!hosts.isEmpty()) {
      for (Host host : hosts) {
        String hostGroupName = host.getHostName();

        Set<String> components = new HashSet<>();
        for (ServiceComponentHost sch : cluster.getServiceComponentHosts(host.getHostName())) {
          components.add(sch.getServiceComponentName());
        }
        map.put(hostGroupName, components);
      }
    }
    return map;
  }
Retrieves component names mapped by host groups, host name is used as host group identifier
@param cluster cluster for calculating components mapping by host groups
@return map "host group name" -> ["component name1", "component name 2", ...]
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackAdvisorResourceProvider.java