@Transactional
  public int removeCurrentByHost(String hostName) {
    TypedQuery<AlertCurrentEntity> query = m_entityManagerProvider.get().createNamedQuery(
      "AlertCurrentEntity.findByHost", AlertCurrentEntity.class);

    query.setParameter("hostName", hostName);
    List<AlertCurrentEntity> currentEntities = m_daoUtils.selectList(query);
    int removedItems = 0;
    if (currentEntities != null) {
      for (AlertCurrentEntity currentEntity : currentEntities) {
        remove(currentEntity);
        removedItems++;
      }
    }

    // if caching is enabled, invalidate the cache to force the latest values
    // back from the DB
    if (m_configuration.isAlertCacheEnabled()) {
      m_currentAlertCache.invalidateAll();
    }

    // publish the event to recalculate aggregates for every cluster since a host could potentially have several clusters
    try {
      Map<String, Cluster> clusters = m_clusters.get().getClusters();
      for (Map.Entry<String, Cluster> entry : clusters.entrySet()) {
        m_alertEventPublisher.publish(new AggregateAlertRecalculateEvent(
            entry.getValue().getClusterId()));
      }

    } catch (Exception ambariException) {
      LOG.warn("Unable to recalcuate aggregate alerts after removing host {}", hostName);
    }

    return removedItems;
  }
Remove the current alert that matches the given host. This is used in cases
where the host was removed from the cluster.
<p>
This method will also fire an {@link AggregateAlertRecalculateEvent} in
order to recalculate all aggregates.

@param hostName
         the name of the host that the current alerts are being removed for
         (not {@code null}).
@return the number of alerts removed.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java