@RequiresSession
  public List<AlertHistoryEntity> findAll(long clusterId,
      List<AlertState> alertStates) {
    if (null == alertStates || alertStates.size() == 0) {
      return Collections.emptyList();
    }

    TypedQuery<AlertHistoryEntity> query = m_entityManagerProvider.get().createNamedQuery(
        "AlertHistoryEntity.findAllInClusterWithState",
        AlertHistoryEntity.class);

    query.setParameter("clusterId", clusterId);
    query.setParameter("alertStates", alertStates);

    return m_daoUtils.selectList(query);
  }
Gets all alerts stored in the database for the given cluster that have one
of the specified alert states.

@param clusterId
         the ID of the cluster.
@param alertStates
         the states to match for the retrieved alerts (not {@code null}).
@return the alerts matching the specified states and cluster, or an empty
        list if none.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java