@Override
  public Collection<HostGroup> getHostGroupsForService(String service) {
    Collection<HostGroup> resultGroups = new HashSet<>();
    for (HostGroup group : hostGroups.values() ) {
      if (group.getServices().contains(service)) {
        resultGroups.add(group);
      }
    }
    return resultGroups;
  }
Get host groups which contain a component for the given service.

@param service   service name

@return collection of host groups which contain a component of the specified service
ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java