private Map<String, Map<String, String>> getEffectiveDesiredTags(Cluster cluster, Map<String,
          DesiredConfig> clusterDesired, Map<String, HostConfig> hostConfigOverrides) {

    if (null == cluster) {
      clusterDesired = new HashMap<>();
    }

    // per method contract, lookup if not supplied
    if (null == clusterDesired) {
      clusterDesired = cluster.getDesiredConfigs();
    }

    if (null == clusterDesired) {
      clusterDesired = new HashMap<>();
    }

    Map<String, Map<String, String>> resolved = new TreeMap<>();

    // Do not use host component config mappings.  Instead, the rules are:
    // 1) Use the cluster desired config
    // 2) override (1) with config-group overrides

    for (Entry<String, DesiredConfig> clusterEntry : clusterDesired.entrySet()) {
      String type = clusterEntry.getKey();
      String tag = clusterEntry.getValue().getTag();

      // 1) start with cluster config
      if (cluster != null) {
        Config config = cluster.getConfig(type, tag);
        if (null == config) {
          continue;
        }

        Map<String, String> tags = new LinkedHashMap<>();

        tags.put(CLUSTER_DEFAULT_TAG, config.getTag());

        // AMBARI-3672. Only consider Config groups for override tags
        // tags -> (configGroupId, versionTag)
        if (hostConfigOverrides != null) {
          HostConfig hostConfig = hostConfigOverrides.get(config.getType());
          if (hostConfig != null) {
            for (Entry<Long, String> tagEntry : hostConfig
                    .getConfigGroupOverrides().entrySet()) {
              tags.put(tagEntry.getKey().toString(), tagEntry.getValue());
            }
          }
        }

        resolved.put(type, tags);
      }
    }

    return resolved;
  }
Gets the desired tags for a cluster and overrides for a host

@param cluster
         the cluster
@param hostConfigOverrides
         the host overrides applied using config groups
@param clusterDesired
         the desired configurations for the cluster. Obtaining these can be
         expensive, ans since this method could be called 10,000's of times
         when generating cluster/host responses. Therefore, the caller
         should build these once and pass them in. If {@code null}, then
         this method will retrieve them at runtime, incurring a performance
         penality.
@return a map of tag type to tag names with overrides
ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java