@Experimental(feature = ExperimentalFeature.CUSTOM_SERVICE_REPOS,
     comment = "Remove logic for handling custom service repos after enabling multi-mpack cluster deployment")
   private Collection<RepositoryInfo> getUniqueServiceRepos(List<RepositoryInfo> stackRepos) {
    List<RepositoryInfo> serviceRepos = getAllServiceRepos();
    ImmutableListMultimap<String, RepositoryInfo> serviceReposByOsType = Multimaps.index(serviceRepos, RepositoryInfo.GET_OSTYPE_FUNCTION);
    ImmutableListMultimap<String, RepositoryInfo> stackReposByOsType = Multimaps.index(stackRepos, RepositoryInfo.GET_OSTYPE_FUNCTION);
     Map<String, RepositoryInfo> uniqueServiceRepos = new HashMap<>();

    // Uniqueness is checked for each os type
    for (String osType: serviceReposByOsType.keySet()) {
      List<RepositoryInfo> stackReposForOsType = stackReposByOsType.containsKey(osType) ? stackReposByOsType.get(osType) : Collections.emptyList();
      List<RepositoryInfo> serviceReposForOsType = serviceReposByOsType.get(osType);
      Set<String> stackRepoNames = ImmutableSet.copyOf(Lists.transform(stackReposForOsType, RepositoryInfo.GET_REPO_NAME_FUNCTION));
      Set<String> stackRepoUrls = ImmutableSet.copyOf(Lists.transform(stackReposForOsType, RepositoryInfo.SAFE_GET_BASE_URL_FUNCTION));
      Set<String> duplicateServiceRepoNames = findDuplicates(serviceReposForOsType, RepositoryInfo.GET_REPO_NAME_FUNCTION);
      Set<String> duplicateServiceRepoUrls = findDuplicates(serviceReposForOsType, RepositoryInfo.SAFE_GET_BASE_URL_FUNCTION);

      for (RepositoryInfo repo: serviceReposForOsType) {
        // These cases only generate warnings
        if (stackRepoUrls.contains(repo.getBaseUrl())) {
          LOG.warn("Service repo has a base url that is identical to that of a stack repo: {}", repo);
        }
        else if (duplicateServiceRepoUrls.contains(repo.getBaseUrl())) {
          LOG.warn("Service repo has a base url that is identical to that of another service repo: {}", repo);
        }
        // These cases cause the repo to be disregarded
        if (stackRepoNames.contains(repo.getRepoName())) {
          LOG.warn("Discarding service repository with the same name as one of the stack repos: {}", repo);
        }
        else if (duplicateServiceRepoNames.contains(repo.getRepoName())) {
          LOG.warn("Discarding service repository with duplicate name and different content: {}", repo);
        }
        else {
          String key = repo.getOsType() + "-" + repo.getRepoName() + "-" + repo.getRepoId();
          if(uniqueServiceRepos.containsKey(key)) {
            uniqueServiceRepos.get(key).getApplicableServices().addAll(repo.getApplicableServices());
          } else {
            uniqueServiceRepos.put(key, repo);
          }
        }
      }
    }
    return uniqueServiceRepos.values();
  }
Gets the service repos with duplicates filtered out. A service repo is considered duplicate if:
<ul>
  <li>It has the same name as a stack repo</li>
  <li>It has the same id as another service repo</li>
</ul>
Duplicate repo url's only results in warnings in the log. Duplicates are checked per os type, so e.g. the same repo
can exsist for centos5 and centos6.
@param stackRepos the list of stack repositories
@return the service repos with duplicates filtered out.
ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java