@Subscribe
  @AllowConcurrentEvents
  public void onEvent(MaintenanceModeEvent event) {
    LOG.debug("Received event {}", event);

    boolean recalculateAggregateAlert = false;
    List<AlertCurrentEntity> currentAlerts = m_alertsDao.findCurrent();

    MaintenanceState newMaintenanceState = MaintenanceState.OFF;
    if (event.getMaintenanceState() != MaintenanceState.OFF) {
      newMaintenanceState = MaintenanceState.ON;
    }
    Map<Long, Map<String, AlertSummaryGroupedRenderer.AlertDefinitionSummary>> alertUpdates = new HashMap<>();
    for( AlertCurrentEntity currentAlert : currentAlerts ){
      AlertHistoryEntity history = currentAlert.getAlertHistory();

      String alertHostName = history.getHostName();
      String alertServiceName = history.getServiceName();
      String alertComponentName = history.getComponentName();

      try {
        Host host = event.getHost();
        Service service = event.getService();
        ServiceComponentHost serviceComponentHost = event.getServiceComponentHost();

        // host level maintenance
        if( null != host ){
          String hostName = host.getHostName();
          if( hostName.equals( alertHostName ) ){
            if (updateMaintenanceStateAndRecalculateAggregateAlert(history, currentAlert, newMaintenanceState, alertUpdates))
              recalculateAggregateAlert = true;
            continue;
          }
        } else if( null != service ){
          // service level maintenance
          String serviceName = service.getName();
          if( serviceName.equals(alertServiceName)){
            if (updateMaintenanceStateAndRecalculateAggregateAlert(history, currentAlert, newMaintenanceState, alertUpdates))
              recalculateAggregateAlert = true;
            continue;
          }
        } else if( null != serviceComponentHost ){
          // component level maintenance
          String hostName = serviceComponentHost.getHostName();
          String serviceName = serviceComponentHost.getServiceName();
          String componentName = serviceComponentHost.getServiceComponentName();

          // match on all 3 for a service component
          if (hostName.equals(alertHostName) && serviceName.equals(alertServiceName)
              && componentName.equals(alertComponentName)) {
            if (updateMaintenanceStateAndRecalculateAggregateAlert(history, currentAlert, newMaintenanceState, alertUpdates))
              recalculateAggregateAlert = true;
            continue;
          }
        }
      } catch (Exception exception) {
        AlertDefinitionEntity definition = history.getAlertDefinition();
        LOG.error("Unable to put alert '{}' for host {} into maintenance mode",
            definition.getDefinitionName(), alertHostName, exception);
      }
    }

    if (!alertUpdates.isEmpty()) {
      STOMPUpdatePublisher.publish(new AlertUpdateEvent(alertUpdates));
    }

    if (recalculateAggregateAlert) {
      // publish the event to recalculate aggregates
      m_alertEventPublisher.publish(new AggregateAlertRecalculateEvent(clusterId));
    }
  }
Handles {@link MaintenanceModeEvent} by performing the following tasks:
<ul>
<li>Iterates through all {@link AlertNoticeEntity}, updating the MM state</li>
</ul>

@param event
         the event being handled.
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertMaintenanceModeListener.java