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

    long clusterId = event.getClusterId();

    // load the host-only alert definitions
    List<AlertDefinition> agentDefinitions = m_ambariServiceAlertDefinitions.getAgentDefinitions();
    List<AlertDefinition> serverDefinitions = m_ambariServiceAlertDefinitions.getServerDefinitions();

    List<AlertDefinition> ambariServiceDefinitions = new ArrayList<>();
    ambariServiceDefinitions.addAll(agentDefinitions);
    ambariServiceDefinitions.addAll(serverDefinitions);

    // lock to prevent multiple threads from trying to create alert
    // definitions at the same time
    m_hostAlertLock.lock();

    try {
      for (AlertDefinition agentDefinition : ambariServiceDefinitions) {
        AlertDefinitionEntity definition = m_alertDefinitionDao.findByName(
            clusterId, agentDefinition.getName());

        // this host definition does not exist, add it
        if (null == definition) {
          definition = m_alertDefinitionFactory.coerce(clusterId,
              agentDefinition);

          try {
            m_alertDefinitionDao.create(definition);
          } catch (Exception e) {
            LOG.error(
                "Unable to create an alert definition named {} in cluster {}",
                definition.getDefinitionName(), definition.getClusterId(), e);
          }
        }
      }
    } finally {
      m_hostAlertLock.unlock();
    }

    for (String hostName : event.getHostNames()) {
      AlertHashInvalidationEvent invalidationEvent = new AlertHashInvalidationEvent(
        event.getClusterId(), Collections.singletonList(hostName));

      m_eventPublisher.publish(invalidationEvent);
    }
  }
Handles the {@link HostsAddedEvent} by performing the following actions:
<ul>
<li>Ensures that all host-level alerts are loaded for the cluster. This is
especially useful when creating a cluster and no alerts were loaded on
Ambari startup</li>
<li>Broadcasts the {@link AlertHashInvalidationEvent} in order to push host
alert definitions</li>
</ul>
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertHostListener.java