public Set<String> getAssociatedHosts(Cluster cluster,
      SourceType definitionSourceType, String definitionName,
      String definitionServiceName, String definitionComponentName) {

    if (definitionSourceType == SourceType.AGGREGATE) {
      return Collections.emptySet();
    }

    String clusterName = cluster.getClusterName();
    Map<String, Host> hosts = m_clusters.get().getHostsForCluster(clusterName);
    Set<String> affectedHosts = new HashSet<>();

    String ambariServiceName = RootService.AMBARI.name();
    String agentComponentName = RootComponent.AMBARI_AGENT.name();

    // intercept host agent alerts; they affect all hosts
    if (ambariServiceName.equals(definitionServiceName)
        && agentComponentName.equals(definitionComponentName)) {
      affectedHosts.addAll(hosts.keySet());
      return affectedHosts;
    }

    // ignore other AMBARI components as they are server-side only
    if (ambariServiceName.equalsIgnoreCase(definitionServiceName)) {
      return Collections.emptySet();
    }

    // find all hosts that have the matching service and component
    for (String hostName : hosts.keySet()) {
      List<ServiceComponentHost> hostComponents = cluster.getServiceComponentHosts(hostName);
      if (null == hostComponents || hostComponents.size() == 0) {
        continue;
      }

      // if a host has a matching service/component, invalidate it
      for (ServiceComponentHost component : hostComponents) {
        String serviceName = component.getServiceName();
        String componentName = component.getServiceComponentName();
        if (serviceName.equals(definitionServiceName)
            && componentName.equals(definitionComponentName)) {
          affectedHosts.add(hostName);
        }
      }
    }

    // get the service that this alert definition is associated with
    Map<String, Service> services = cluster.getServices();
    Service service = services.get(definitionServiceName);
    if (null == service) {
      LOG.warn("The alert definition {} has an unknown service of {}",
          definitionName, definitionServiceName);

      return affectedHosts;
    }

    // get all master components of the definition's service; any hosts that
    // run the master should be invalidated as well
    Map<String, ServiceComponent> components = service.getServiceComponents();
    if (null != components) {
      for (Entry<String, ServiceComponent> component : components.entrySet()) {
        if (component.getValue().isMasterComponent()) {
          Map<String, ServiceComponentHost> componentHosts = component.getValue().getServiceComponentHosts();
          if (null != componentHosts) {
            affectedHosts.addAll(componentHosts.keySet());
          }
        }
      }
    }

    return affectedHosts;
  }
Gets the hosts that are associated with the specified definition. Each host
returned is expected to be capable of running the alert. A change to the
definition would entail contacting each returned host and invalidating
their current alert definitions.
<p/>
If the definition is an {@link SourceType#AGGREGATE}, this will return an
empty set since aggregates do not affect hosts.

@param cluster
@param definitionName
@param definitionServiceName
@param definitionComponentName
@return a set of all associated hosts or an empty set, never {@code null}.
ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java