private void populateResource(Resource resource, Set<String> requestedIds, Map<Long, Map<String, 
      AlertSummaryDTO>> perHostSummaryMap, Map<Long, AlertHostSummaryDTO> hostsSummaryMap) throws AmbariException {

    AlertSummaryDTO summary = null;
    AlertHostSummaryDTO hostSummary = null;

    String clusterName = (String) resource.getPropertyValue(m_clusterPropertyId);

    if (null == clusterName) {
      return;
    }

    String typeId = null == m_typeIdPropertyId ? null : (String) resource.getPropertyValue(m_typeIdPropertyId);
    Cluster cluster = s_clusters.get().getCluster(clusterName);

    switch (m_resourceType.getInternalType()) {
      case Cluster:
        long clusterId = cluster.getClusterId();

        // only make the calculation if asked
        if (BaseProvider.isPropertyRequested(ALERTS_SUMMARY, requestedIds)) {
          summary = s_dao.findCurrentCounts(cluster.getClusterId(), null, null);
        }

        // only make the calculation if asked
        if (BaseProvider.isPropertyRequested(ALERTS_SUMMARY_HOSTS,
            requestedIds)) {
          if (hostsSummaryMap.containsKey(cluster.getClusterId())) {
            hostSummary = hostsSummaryMap.get(cluster.getClusterId());
          } else {
            hostSummary = s_dao.findCurrentHostCounts(clusterId);
          }
        }

        break;
      case Service:
        summary = s_dao.findCurrentCounts(cluster.getClusterId(), typeId, null);
        break;
      case Host:
      if (perHostSummaryMap.containsKey(cluster.getClusterId()) && 
          perHostSummaryMap.get(cluster.getClusterId()).containsKey(typeId)) {
        summary = perHostSummaryMap.get(cluster.getClusterId()).get(typeId);
      } else {
        summary = s_dao.findCurrentCounts(cluster.getClusterId(), null, typeId);
      }
        break;
      default:
        break;
    }

    // all alerts in the cluster, in summary count form
    if (null != summary) {
      Map<String, Integer> map = new HashMap<>();
      map.put(AlertState.OK.name(), Integer.valueOf(summary.getOkCount()));
      map.put(AlertState.WARNING.name(), Integer.valueOf(summary.getWarningCount()));
      map.put(AlertState.CRITICAL.name(), Integer.valueOf(summary.getCriticalCount()));
      map.put(AlertState.UNKNOWN.name(), Integer.valueOf(summary.getUnknownCount()));
      map.put("MAINTENANCE", Integer.valueOf(summary.getMaintenanceCount()));
      setResourceProperty(resource, ALERTS_SUMMARY, map, requestedIds);
    }

    // the summary of hosts with warning or critical alerts
    if (null != hostSummary) {
      Map<AlertState, Integer> map = new HashMap<>();
      map.put(AlertState.OK, Integer.valueOf(hostSummary.getOkCount()));
      map.put(AlertState.WARNING, Integer.valueOf(hostSummary.getWarningCount()));
      map.put(AlertState.CRITICAL, Integer.valueOf(hostSummary.getCriticalCount()));
      map.put(AlertState.UNKNOWN, Integer.valueOf(hostSummary.getUnknownCount()));
      setResourceProperty(resource, ALERTS_SUMMARY_HOSTS, map, requestedIds);
    }

  }
Constructor.

@param type
@param clusterPropertyId
@param typeIdPropertyId
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertSummaryPropertyProvider.java