private void resolveStack(
          StackModule stackToBeResolved, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions)
          throws AmbariException {
    if (stackToBeResolved.getModuleState() == ModuleState.INIT) {
      stackToBeResolved.resolve(null, allStacks, commonServices, extensions);
    } else if (stackToBeResolved.getModuleState() == ModuleState.VISITED) {
      //todo: provide more information to user about cycle
      throw new AmbariException("Cycle detected while parsing stack definition");
    }
    if (!stackToBeResolved.isValid() || (stackToBeResolved.getModuleInfo() != null && !stackToBeResolved.getModuleInfo().isValid())) {
      setValid(stackToBeResolved.isValid());
      stackInfo.setValid(stackToBeResolved.stackInfo.isValid());
      addErrors(stackToBeResolved.getErrors());
      stackInfo.addErrors(stackToBeResolved.getErrors());
    }
  }
Resolve another stack module.

@param stackToBeResolved  stack module to be resolved
@param allStacks          all stack modules in stack definition
@param commonServices     all common services specified in the stack definition
@throws AmbariException if unable to resolve the stack
ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java