private boolean canDispatch(AlertTargetEntity target,
      AlertHistoryEntity history, AlertDefinitionEntity definition) {

    // disable alert targets should be skipped
    if (!target.isEnabled()) {
      return false;
    }

    Set<AlertState> alertStates = target.getAlertStates();
    if (null != alertStates && alertStates.size() > 0) {
      if (!alertStates.contains(history.getAlertState())) {
        return false;
      }
    }

    // check if in an upgrade
    Long clusterId = history.getClusterId();
    try {
      Cluster cluster = m_clusters.get().getClusterById(clusterId);
      if (null != cluster.getUpgradeInProgress()) {
        // only send AMBARI alerts if in an upgrade
        String serviceName = definition.getServiceName();
        if (!StringUtils.equals(serviceName, RootService.AMBARI.name())) {
          LOG.debug(
              "Skipping alert notifications for {} because the cluster is upgrading",
              definition.getDefinitionName(), target);

          return false;
        }
      }
    } catch (AmbariException ambariException) {
      LOG.warn(
          "Unable to process an alert state change for cluster with ID {} because it does not exist",
          clusterId);

      return false;
    }

    return true;
  }
Gets whether an {@link AlertNoticeEntity} should be created for the
{@link AlertHistoryEntity} and {@link AlertTargetEntity}. Reasons this
would be false include:
<ul>
<li>The target is disabled
<li>The target is not configured for the state of the alert
<li>The cluster is upgrading and the alert is cluster-related
</ul>

@param target
         the target (not {@code null}).
@param history
         the history entry that represents the state change (not
         {@code null}).
@return {@code true} if a notification should be dispatched for the target,
        {@code false} otherwise.
@see AlertTargetEntity#isEnabled()
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertStateChangedListener.java