private Collection<ServiceComponentHost> filterServiceComponentHostsForHosts(Collection<ServiceComponentHost> serviceComponentHosts,
                                                                               Set<String> hosts) {

    if ((serviceComponentHosts != null) && (hosts != null)) {
      Iterator<ServiceComponentHost> iterator = serviceComponentHosts.iterator();
      while (iterator.hasNext()) {
        ServiceComponentHost sch = iterator.next();

        if (!hosts.contains(sch.getHostName())) {
          iterator.remove();
        }
      }
    }

    return serviceComponentHosts;
  }
Filter out ServiceComponentHosts that are on on hosts in the specified set of host names.
<p/>
It is expected that the supplied collection is modifiable. It will be modified inplace.

@param serviceComponentHosts a collection of ServiceComponentHost items to test
@param hosts                 a set of host names indicating valid hosts
@return a collection of filtered ServiceComponentHost items
ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java