public Map<String, Collection<String>> adjustServiceComponentFilter(Cluster cluster, boolean includeAmbariAsService, Map<String, ? extends Collection<String>> serviceComponentFilter) throws AmbariException {
    Map<String, Collection<String>> adjustedFilter = new HashMap<>();

    Map<String, Service> installedServices = (cluster == null) ? null : cluster.getServices();
    if(includeAmbariAsService) {
      installedServices = (installedServices == null) ? new HashMap<>() : new HashMap<>(installedServices);
      installedServices.put("AMBARI", null);
    }

    if (!MapUtils.isEmpty(installedServices)) {
      if (serviceComponentFilter != null) {
        // prune off services that are not installed, or considered installed - like AMBARI
        for (Map.Entry<String, ? extends Collection<String>> entry : serviceComponentFilter.entrySet()) {
          String serviceName = entry.getKey();

          if (installedServices.containsKey(serviceName)) {
            adjustedFilter.put(serviceName, entry.getValue());
          }
        }
      } else {
        // return only the set of installed services
        for (String serviceName : installedServices.keySet()) {
          // Add an entry to indicate the service and all of it's components should be considered
          adjustedFilter.put(serviceName, Collections.singletonList("*"));
        }
      }
    }

    return adjustedFilter;
  }
Adjust service component filter according to installed services

@param cluster                cluster
@param includeAmbariAsService
@param serviceComponentFilter
@return
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/stageutils/KerberosKeytabController.java