private void mergeServicesWithParent(
      StackModule parentStack, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions)
      throws AmbariException {
    stackInfo.getServices().clear();
    Collection<ServiceModule> mergedModules = mergeChildModules(
        allStacks, commonServices, extensions, serviceModules, parentStack.serviceModules);

    List<String> removedServices = new ArrayList<>();

    for (ServiceModule module : mergedModules) {
      if (module.isDeleted()){
        removedServices.add(module.getId());
      } else {
        serviceModules.put(module.getId(), module);
        stackInfo.getServices().add(module.getModuleInfo());
      }
    }
    stackInfo.setRemovedServices(removedServices);
  }
Merge child services with parent stack.

@param parentStack    parent stack module
@param allStacks      all stacks in stack definition
@param commonServices all common services specified in the stack definition

@throws AmbariException if an exception occurs merging the child services with the parent stack
ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java