protected void processCluster(Cluster cluster, StackAdvisorRequest.StackAdvisorRequestType stackAdvisorRequestType) throws AmbariException, StackAdvisorException {
    final StackId stackVersion = cluster.getCurrentStackVersion();
    final List<String> hosts = cluster.getHosts().stream().map(Host::getHostName).collect(Collectors.toList());
    final Set<String> serviceNames = cluster.getServices().values().stream().map(Service::getName).collect(Collectors.toSet());

    final StackAdvisorRequest request = StackAdvisorRequest.StackAdvisorRequestBuilder
        .forStack(stackVersion.getStackName(), stackVersion.getStackVersion())
        .ofType(stackAdvisorRequestType)
        .forHosts(hosts)
        .forServices(serviceNames)
        .withComponentHostsMap(cluster.getServiceComponentHostMap(null, null))
        .withConfigurations(calculateExistingConfigurations(cluster))
        .build();

    // Execute the stack advisor
    final RecommendationResponse response = stackAdvisorHelper.recommend(request);

    // Process the recommendations and automatically apply them. Ideally this is what the user wanted
    final RecommendationResponse.Recommendation recommendation = (response == null) ? null : response.getRecommendations();
    final RecommendationResponse.Blueprint blueprint = (recommendation == null) ? null : recommendation.getBlueprint();
    final Map<String, RecommendationResponse.BlueprintConfigurations> configurations = (blueprint == null) ? null : blueprint.getConfigurations();

    if (configurations != null) {
      for (Map.Entry<String, RecommendationResponse.BlueprintConfigurations> configuration : configurations.entrySet()) {
        processConfigurationType(cluster, configuration.getKey(), configuration.getValue());
      }
    }
  }
Build the stack advisor request, call the stack advisor, then automatically
handle the recommendations.
<p>
Any recommendation coming back from the Stack/service advisor is expected to
be only related configurations of the given request type (LDAP/SSO)
<p>
If there are no changes to the current configurations, no new configuration
versions will be created.

@param cluster
         the cluster to process
@param stackAdvisorRequestType
         the stack advisor request type
@throws AmbariException
@throws StackAdvisorException
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerStackAdvisorAwareConfigurationHandler.java