StackAdvisorCommand<RecommendationResponse> createRecommendationCommand(String serviceName, StackAdvisorRequest request) throws StackAdvisorException {
    StackAdvisorRequestType requestType = request.getRequestType();
    ServiceInfo.ServiceAdvisorType serviceAdvisorType = getServiceAdvisorType(request.getStackName(), request.getStackVersion(), serviceName);

    StackAdvisorCommand<RecommendationResponse> command;
    if (requestType == StackAdvisorRequestType.HOST_GROUPS) {
      command = new ComponentLayoutRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, serviceAdvisorType,
          requestId, saRunner, metaInfo, ambariServerConfigurationHandler);
    } else if (requestType == StackAdvisorRequestType.CONFIGURATIONS) {
      command = new ConfigurationRecommendationCommand(StackAdvisorCommandType.RECOMMEND_CONFIGURATIONS, recommendationsDir, recommendationsArtifactsLifetime, serviceAdvisorType,
          requestId, saRunner, metaInfo, ambariServerConfigurationHandler, hostInfoCache);
    } else if (requestType == StackAdvisorRequestType.SSO_CONFIGURATIONS) {
      command = new ConfigurationRecommendationCommand(StackAdvisorCommandType.RECOMMEND_CONFIGURATIONS_FOR_SSO, recommendationsDir, recommendationsArtifactsLifetime, serviceAdvisorType,
          requestId, saRunner, metaInfo, ambariServerConfigurationHandler, null);
    } else if (requestType == StackAdvisorRequestType.LDAP_CONFIGURATIONS) {
      command = new ConfigurationRecommendationCommand(StackAdvisorCommandType.RECOMMEND_CONFIGURATIONS_FOR_LDAP, recommendationsDir, recommendationsArtifactsLifetime, serviceAdvisorType,
          requestId, saRunner, metaInfo, ambariServerConfigurationHandler, null);
    } else if (requestType == StackAdvisorRequestType.KERBEROS_CONFIGURATIONS) {
      command = new ConfigurationRecommendationCommand(StackAdvisorCommandType.RECOMMEND_CONFIGURATIONS_FOR_KERBEROS, recommendationsDir, recommendationsArtifactsLifetime, serviceAdvisorType,
          requestId, saRunner, metaInfo, ambariServerConfigurationHandler, null);
    } else if (requestType == StackAdvisorRequestType.CONFIGURATION_DEPENDENCIES) {
      command = new ConfigurationDependenciesRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, serviceAdvisorType,
          requestId, saRunner, metaInfo, ambariServerConfigurationHandler);
    } else {
      throw new StackAdvisorRequestException(String.format("Unsupported request type, type=%s",
          requestType));
    }

    return command;
  }
Returns recommendation (component-layout or configurations) based on the
request.

@param request the recommendation request
@return {@link RecommendationResponse} instance
@throws StackAdvisorException in case of stack advisor script errors
ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorHelper.java