@Subscribe
  @AllowConcurrentEvents
  public void onAmbariEvent(ServiceInstalledEvent event) {

    Clusters clusters = clustersProvider.get();
    Long clusterId = event.getClusterId();

    try {
      org.apache.ambari.server.state.Cluster cluster = clusters.getClusterById(clusterId);
      String clusterName = cluster.getClusterName();

      Set<StackId> stackIds = new HashSet<>();
      Set<String> serviceNames = cluster.getServices().keySet();

      for (String serviceName : serviceNames) {
        Service service = cluster.getService(serviceName);
        stackIds.add(service.getDesiredStackId());
      }

      for (ViewEntity viewEntity : getDefinitions()) {

        String viewName = viewEntity.getName();
        ViewConfig viewConfig = viewEntity.getConfiguration();
        AutoInstanceConfig autoConfig = viewConfig.getAutoInstance();
        Collection<String> roles = com.google.common.collect.Lists.newArrayList();
        if (autoConfig != null && !CollectionUtils.isEmpty(autoConfig.getRoles())) {
          roles.addAll(autoConfig.getRoles());
        }

        for (StackId stackId : stackIds) {
          try {
            if (checkAutoInstanceConfig(autoConfig, stackId, event.getServiceName(), serviceNames)) {
              installAutoInstance(clusterId, clusterName, cluster.getService(event.getServiceName()), viewEntity, viewName, viewConfig, autoConfig, roles);
            }
          } catch (Exception e) {
            LOG.error("Can't auto create instance of view " + viewName + " for cluster " + clusterName +
              ".  Caught exception :" + e.getMessage(), e);
          }
        }
      }
    } catch (AmbariException e) {
      LOG.warn("Unknown cluster id " + clusterId + ".");
    }
  }
Receive notification that a new service has been added to a cluster.
</p>
Used for view instance auto creation.

@param event the service installed event
ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java