static Map<String, Set<String>> getHostComponentMap(Map<String, Set<String>> componentHostMap) {
    return componentHostMap.entrySet().stream()
      .flatMap(compHosts -> compHosts.getValue().stream().map(host -> Pair.of(host, compHosts.getKey())))
      .collect(groupingBy(Pair::getKey, mapping(Pair::getValue, toSet())));
  }
Transform a map of component -> hosts to a map of hosts -> components
@param componentHostMap the map to transform
@return the transformed map
ambari-server/src/main/java/org/apache/ambari/server/topology/addservice/StackAdvisorAdapter.java