private boolean checkAutoInstanceConfig(AutoInstanceConfig autoConfig, StackId stackId,
                                          String serviceName, Set<String> serviceNames) {

    if (autoConfig != null) {
      List<String> autoCreateServices = autoConfig.getServices();

      if (autoCreateServices != null && autoCreateServices.contains(serviceName) &&
          serviceNames.containsAll(autoCreateServices)) {

        String configStackId = autoConfig.getStackId();

        if (configStackId != null) {
          if (configStackId.equals("*")) {
            // always return true when the auto-instance is configured to match
            // against all stacks
            return true;
          }

          StackId id = new StackId(configStackId);

          if (id.getStackName().equals(stackId.getStackName())) {

            String stackVersion = stackId.getStackVersion();
            String configStackVersion = id.getStackVersion();

            // make sure that the configured stack version equals the cluster stack version (account for *)
            int compVal = 0;

            int index = configStackVersion.indexOf('*');
            if (index == -1) {
              compVal = VersionUtils.compareVersions(configStackVersion, stackVersion);
            } else if (index > 0) {
              String[] parts = configStackVersion.substring(0, index).split("\\.");
              compVal = VersionUtils.compareVersions(configStackVersion, stackVersion, parts.length);
            }

            return compVal == 0;
          }
        }
      }
    }
    return false;
  }
Determine whether a new view instance should be automatically created and associated with
a cluster based on the given configuration and cluster state.

@param autoConfig   the view instance auto creation configuration
@param stackId      the stack id of the cluster
@param serviceName  the name of the service added which triggered this check
@param serviceNames the set of service names of the cluster
@return true if a new view instance should be created
ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java