private VersionDefinitionXml mergeDefinitions(StackId stackId, String version,
      Map<String, String> osMap, Map<URI, VersionDefinitionXml> parsedMap) throws Exception {

    Set<String> oses = new HashSet<>();
    for (RepositoryInfo ri : stack.getRepositories()) {
      if (null != os_family.find(ri.getOsType())) {
        oses.add(os_family.find(ri.getOsType()));
      }
    }

    VersionDefinitionXml.Merger merger = new VersionDefinitionXml.Merger();

    for (Entry<String, String> versionEntry : osMap.entrySet()) {

      String osFamily = os_family.find(versionEntry.getKey());

      // !!! check for aliases.  Moving this to OsFamily could result in incorrect behavior
      if (null == osFamily) {
        String alias = os_family.getAliases().get(versionEntry.getKey());
        if (null != alias) {
          osFamily = os_family.find(alias);
        }
      }

      // !!! if the family is not known OR not part of the stack, skip
      if (null == osFamily || !oses.contains(osFamily)) {
        LOG.info("Stack {} cannot resolve OS {} to the supported ones: {}. Family: {}",
            stackId, versionEntry.getKey(), StringUtils.join(oses, ','), osFamily);
        continue;
      }

      String uriString = versionEntry.getValue();

      if ('.' == uriString.charAt(0)) {
        uriString = new File(stackRepoFolder, uriString).toURI().toString();
      }

      try {
        URI uri = new URI(uriString);

        VersionDefinitionXml xml = parsedMap.containsKey(uri) ? parsedMap.get(uri) :
           timedVDFLoad(uri);

        version = (null == version) ? xml.release.version : version;
        merger.add(version, xml);

        if (!parsedMap.containsKey(uri)) {
          parsedMap.put(uri, xml);
        }

      } catch (Exception e) {
        LOG.warn("Could not load version definition for {} identified by {}. {}",
            stackId, uriString, e.getMessage(), e);
      }
    }

    return merger.merge();
  }
Merges definitions loaded from the common file
@param stackId the stack id
@param version the version string
@param osMap   the map containing all the VDF for an OS
@return the merged version definition
@throws Exception
ambari-server/src/main/java/org/apache/ambari/server/state/stack/LatestRepoCallable.java