private List<String> calculateHosts(Cluster cluster, List<ServiceComponentHost> serviceComponentHosts, Set<String> hostsWithValidKerberosClient, boolean forceAllHosts) throws AmbariException {
    if (forceAllHosts) {
      List<String> hosts = new ArrayList<>();
      Collection<Host> clusterHosts = cluster.getHosts();
      if (!CollectionUtils.isEmpty(clusterHosts)) {
        for (Host host : clusterHosts) {
          if (host.getState() == HostState.HEALTHY) {
            hosts.add(host.getHostName());
          } else {
            LOG.warn("Host {} was excluded due {} state", host.getHostName(), host.getState());
          }
        }
      }

      return hosts;
    } else {
      Collection<ServiceComponentHost> filteredComponents = filterServiceComponentHostsForHosts(
        new ArrayList<>(serviceComponentHosts), hostsWithValidKerberosClient);

      if (filteredComponents.isEmpty()) {
        return Collections.emptyList();
      } else {
        return createUniqueHostList(filteredComponents, Collections.singleton(HostState.HEALTHY));
      }
    }
  }
Calculate the hosts to include when issuing agent-side commands.
<p>
If forcing all hosts, select only the healthy hosts in the cluster else select only the healthy
hosts from the set of hosts specified in the collection of relevant {@link ServiceComponentHost}.

@param cluster                      the cluster
@param serviceComponentHosts        a collction of {@link ServiceComponentHost}s that are
                                    relevant to the current operation
@param hostsWithValidKerberosClient the collection of hosts know to have the Kerberos client
                                    component installed
@param forceAllHosts                true to process all hosts from the cluster rather than use
                                    the hosts parsed from the set of {@link ServiceComponentHost}s
@return a filtered list of host names
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java