@RequiresSession
  public AlertHostSummaryDTO findCurrentHostCounts(long clusterId) {
    String sql = String.format(ALERT_COUNT_PER_HOST_SQL_TEMPLATE, HostAlertSummaryDTO.class.getName());

    StringBuilder sb = new StringBuilder(sql);

    TypedQuery<HostAlertSummaryDTO> query = m_entityManagerProvider.get().createQuery(sb.toString(), HostAlertSummaryDTO.class);

    query.setParameter("clusterId", Long.valueOf(clusterId));
    query.setParameter("okState", AlertState.OK);
    query.setParameter("criticalState", AlertState.CRITICAL);
    query.setParameter("warningState", AlertState.WARNING);
    query.setParameter("unknownState", AlertState.UNKNOWN);
    query.setParameter("maintenanceStateOff", MaintenanceState.OFF);

    int okCount = 0;
    int warningCount = 0;
    int criticalCount = 0;
    int unknownCount = 0;

    List<HostAlertSummaryDTO> resultList = m_daoUtils.selectList(query);
    for (HostAlertSummaryDTO result : resultList) {
      if (result.getHostName() == null) {
        continue;
      }
      if (result.getCriticalCount() > 0) {
        criticalCount++;
      }
      else if (result.getWarningCount() > 0) {
        warningCount++;
      }
      else if (result.getUnknownCount() > 0) {
        unknownCount++;
      }
      else {
        okCount++;
      }
    }

    AlertHostSummaryDTO hostSummary = new AlertHostSummaryDTO(okCount,
            unknownCount, warningCount, criticalCount);

    return hostSummary;
  }
Retrieve the summary alert information for all hosts. This is different
from {@link #findCurrentCounts(long, String, String)} since this will
return only alerts related to hosts and those values will be the total
number of hosts affected, not the total number of alerts.

@param clusterId
         the cluster id
@return the summary DTO for host alerts.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertsDAO.java