@Transactional
  public int removeCurrentByService(long clusterId, String serviceName) {
    TypedQuery<AlertCurrentEntity> query = m_entityManagerProvider.get().createNamedQuery(
      "AlertCurrentEntity.findByServiceName", AlertCurrentEntity.class);

    query.setParameter("serviceName", serviceName);

    int removedItems = 0;
    List<AlertCurrentEntity> currentEntities = m_daoUtils.selectList(query);
    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
    m_alertEventPublisher.publish(new AggregateAlertRecalculateEvent(clusterId));
    return removedItems;
  }
Remove the current alert that matches the given service. This is used in
cases where the service was removed from the cluster.
<p>
This method will also fire an {@link AggregateAlertRecalculateEvent} in
order to recalculate all aggregates.

@param clusterId
         the ID of the cluster.
@param serviceName
         the name of the service 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