@Transactional
  @Override
  public long cleanup(TimeBasedCleanupPolicy policy) {
    long affectedRows = 0;
    Long clusterId = null;
    try {
      clusterId = m_clusters.get().getCluster(policy.getClusterName()).getClusterId();
      affectedRows += cleanAlertNoticesForClusterBeforeDate(clusterId, policy.getToDateInMillis());
      affectedRows += cleanAlertCurrentsForClusterBeforeDate(clusterId, policy.getToDateInMillis());
      affectedRows += cleanAlertHistoriesForClusterBeforeDate(clusterId, policy.getToDateInMillis());
    } catch (AmbariException e) {
      LOG.error("Error while looking up cluster with name: {}", policy.getClusterName(), e);
      throw new IllegalStateException(e);
    }

    return affectedRows;
  }
Gets a list that is comprised of the original values replaced by any cached
values from {@link #m_currentAlertCache}. This method should only be
invoked if {@link Configuration#isAlertCacheEnabled()} is {@code true}

@param alerts
         the list of alerts to iterate over and replace with cached
         instances.
@return the list of alerts from JPA combined with any cached alerts.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java