private boolean updateMaintenanceStateAndRecalculateAggregateAlert (AlertHistoryEntity historyAlert,
      AlertCurrentEntity currentAlert, MaintenanceState maintenanceState, Map<Long, Map<String,
      AlertSummaryGroupedRenderer.AlertDefinitionSummary>> alertUpdates) {

    AlertDefinitionEntity definitionEntity = currentAlert.getAlertHistory().getAlertDefinition();
    // alerts only care about OFF or ON
    if (maintenanceState != MaintenanceState.OFF && maintenanceState != MaintenanceState.ON) {
      LOG.warn("Unable to set invalid maintenance state of {} on the alert {}", maintenanceState,
          definitionEntity.getDefinitionName());

      return false;
    }

    MaintenanceState currentState = currentAlert.getMaintenanceState();
    if (currentState == maintenanceState) {
      return false;
    }

    currentAlert.setMaintenanceState(maintenanceState);
    m_alertsDao.merge(currentAlert);

    AlertState alertState = historyAlert.getAlertState();

    if (!alertUpdates.containsKey(historyAlert.getClusterId())) {
      alertUpdates.put(historyAlert.getClusterId(), new HashMap<>());
    }
    Map<String, AlertSummaryGroupedRenderer.AlertDefinitionSummary> summaries = alertUpdates.get(historyAlert.getClusterId());

    // alert history doesn't change when MM is turned on/off, so timestamp and text should be empty
    AlertSummaryGroupedRenderer.updateSummary(summaries, definitionEntity.getDefinitionId(),
        definitionEntity.getDefinitionName(), alertState, -1L, maintenanceState, "");

    if (AlertState.RECALCULATE_AGGREGATE_ALERT_STATES.contains(alertState)){
      clusterId = historyAlert.getClusterId();
      String alertName = historyAlert.getAlertDefinition().getDefinitionName();

      if (m_aggregateMapping.getAggregateDefinition(clusterId, alertName) != null){
        return true;
      }
    }
    return false;
  }
Updates the maintenance state of the specified alert if different than the
supplied maintenance state. And recalcualte aggregates if the maintenance state
is changed and there is an aggregate alert for the specified alert if it is
in CRITICAL or WARNING state.

@param historyAlert
         the alert to check if having an aggregate alert associated with it.
@param currentAlert
         the alert to update (not {@code null}).
@param maintenanceState
         the maintenance state to change to, either
         {@link MaintenanceState#OFF} or {@link MaintenanceState#ON}.
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertMaintenanceModeListener.java