public Set<ServiceComponent> unsupportedComponents(Cluster cluster, String stackName, String stackVersion) throws AmbariException {

    Set<ServiceComponent> unsupportedComponents = new HashSet<>();
    for (Service service : cluster.getServices().values()) {
      for (ServiceComponent component : service.getServiceComponents().values()) {
        if (!component.isVersionAdvertised())
          continue;
        if (!isComponentSupported(service.getName(), component.getName(), stackName, stackVersion)) {
          unsupportedComponents.add(component);
        }
      }
    }
    return unsupportedComponents;
  }
Collects the ServiceComponents from the cluster which are not supported (component doesn't exist or was deleted) in the given stack.
Non versionAdvertised components are ignored.
ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentSupport.java