private void fullyResolveStacks(
      Map<String, StackModule> stackModules, Map<String, ServiceModule> commonServiceModules, Map<String, ExtensionModule> extensions)
      throws AmbariException {
    // Resolve all stacks without finalizing the stacks.
    for (StackModule stack : stackModules.values()) {
      if (stack.getModuleState() == ModuleState.INIT) {
        stack.resolve(null, stackModules, commonServiceModules, extensions);
      }
    }
    // Finalize the common services and stacks to remove sub-modules marked for deletion.
    // Finalizing the stacks AFTER all stacks are resolved ensures that the sub-modules marked for deletion are
    // inherited into the child module when explicit parent is defined and thereby ensuring all modules from parent module
    // are inlined into the child module even if the module is marked for deletion.
    for(ServiceModule commonService : commonServiceModules.values()) {
      commonService.finalizeModule();
    }
    for (ExtensionModule extension : extensions.values()) {
      extension.finalizeModule();
    }
    for (StackModule stack : stackModules.values()) {
      stack.finalizeModule();
    }
    // Execute all of the repo tasks in a single thread executor
    stackContext.executeRepoTasks();
  }
Fully resolve all stacks.

@param stackModules          map of stack id which contains name and version to stack module.
@param commonServiceModules  map of common service id which contains name and version to stack module.
@throws AmbariException if unable to resolve all stacks
ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java