@Subscribe
  @AllowConcurrentEvents
  public void handleMaintenanceModeEvent(MaintenanceModeEvent event)
      throws AmbariException {
    if (event.getHost() != null) {
      /*
       * If any one component in the host is recovery enabled,
       * invalidate the host timestamp.
       */
      Cluster cluster = clusters.getCluster(event.getClusterId());
      if (cluster == null) {
        return;
      }

      Host host = event.getHost();
      List<ServiceComponentHost> scHosts = cluster.getServiceComponentHosts(host.getHostName());
      for (ServiceComponentHost sch : scHosts) {
        if (sch.isRecoveryEnabled()) {
          invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName());
          break;
        }
      }
    }
    else if (event.getService() != null) {
      /*
       * Simply invalidate all the hosts in the cluster.
       * The recovery config will be sent to all the hosts
       * even if some of the hosts do not have components
       * in recovery mode.
       * Looping through all the hosts and its components
       * to determine which host to send the recovery config
       * may not be efficient.
       */
      Service service = event.getService();
      invalidateRecoveryTimestamp(service.getCluster().getClusterName(), null);
    }
    else if (event.getServiceComponentHost() != null) {
      ServiceComponentHost sch = event.getServiceComponentHost();

      if (sch.isRecoveryEnabled()) {
        invalidateRecoveryTimestamp(sch.getClusterName(), sch.getHostName());
      }
    }
  }
Maintenance mode of a host, service or service component host changed.
@param event
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java