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

    long clusterId = event.getClusterId();
    String stackName = event.getStackName();
    String stackVersion = event.getStackVersion();
    String serviceName = event.getServiceName();

    Lock lock = m_locksByService.get(serviceName);
    lock.lock();

    try {
      // create the default alert group for the new service if absent; this MUST
      // be done before adding definitions so that they are properly added to the
      // default group
      if (null == m_alertDispatchDao.findDefaultServiceGroup(clusterId, serviceName)) {
        try {
          m_alertDispatchDao.createDefaultGroup(clusterId, serviceName);
        } catch (AmbariException ambariException) {
          LOG.error("Unable to create a default alert group for {}",
            event.getServiceName(), ambariException);
        }
      }

      // populate alert definitions for the new service from the database, but
      // don't worry about sending down commands to the agents; the host
      // components are not yet bound to the hosts so we'd have no way of knowing
      // which hosts are invalidated; do that in another impl
      try {
        Set<AlertDefinition> alertDefinitions = m_metaInfoProvider.get().getAlertDefinitions(
            stackName, stackVersion, serviceName);

        for (AlertDefinition definition : alertDefinitions) {
          AlertDefinitionEntity entity = m_alertDefinitionFactory.coerce(
              clusterId,
              definition);

          m_definitionDao.create(entity);
        }
      } catch (AmbariException ae) {
        String message = MessageFormat.format(
            "Unable to populate alert definitions from the database during installation of {0}",
            serviceName);
        LOG.error(message, ae);
      }
    }
    finally {
      lock.unlock();
    }
  }
Handles service installed events by populating the database with all known
alert definitions for the newly installed service and creates the service's
default alert group.

@param event
         the published event being handled (not {@code null}).
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java