protected Set<RecommendationResponse.ConfigGroup> calculateConfigGroups(Cluster cluster, Request request) {

    Set<RecommendationResponse.ConfigGroup> configGroups = new HashSet<>();

    Set<HashMap<String, Object>> configGroupsProperties =
      (HashSet<HashMap<String, Object>>) getRequestProperty(request, CONFIG_GROUPS_PROPERTY);
    if (configGroupsProperties != null) {
      for (HashMap<String, Object> props : configGroupsProperties) {
        RecommendationResponse.ConfigGroup configGroup = new RecommendationResponse.ConfigGroup();
        Object groupIdObject = props.get(CONFIG_GROUPS_GROUP_ID_PROPERTY);
        if (groupIdObject != null) {
          Long groupId = Long.valueOf((String) groupIdObject);
          ConfigGroup clusterConfigGroup = cluster.getConfigGroupsById(groupId);

          // convert configs
          Map<String, RecommendationResponse.BlueprintConfigurations> typedConfiguration = new HashMap<>();
          for (Map.Entry<String, Config> config : clusterConfigGroup.getConfigurations().entrySet()) {
            RecommendationResponse.BlueprintConfigurations blueprintConfiguration = new RecommendationResponse.BlueprintConfigurations();
            blueprintConfiguration.setProperties(config.getValue().getProperties());
            typedConfiguration.put(config.getKey(), blueprintConfiguration);
          }

          configGroup.setConfigurations(typedConfiguration);

          configGroup.setHosts(clusterConfigGroup.getHosts().values().stream().map(h -> h.getHostName()).collect(Collectors.toList()));
          configGroups.add(configGroup);
        }
      }
    }

    return configGroups;
  }
Retrieves hosts names mapped by host groups, host name is used as host group identifier
@param cluster cluster for calculating hosts mapping by host groups
@return map "host group name" -> ["host name 1"]
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackAdvisorResourceProvider.java