public Map<String, List<StackInfo>> getStacksByName() {
    Map<String, List<StackInfo>> stacks = new HashMap<>();
    for (StackInfo stack: stackMap.values()) {
      List<StackInfo> list = stacks.get(stack.getName());
      if (list == null) {
        list = new ArrayList<>();
        stacks.put(stack.getName(),  list);
      }
      list.add(stack);
    }
    return stacks;
  }
Obtain all a map of all stacks by name.

@return A map of all stacks with the name as the key.
ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java