private static void validateServiceDuplication(StackManager stackManager, StackInfo stack, ExtensionInfo oldExtension, ExtensionInfo newExtension) throws AmbariException {
    ArrayList<ServiceInfo> services = new ArrayList<>(newExtension.getServices().size());
    for (ServiceInfo service : newExtension.getServices()) {
      boolean found = false;
      for (ServiceInfo current : oldExtension.getServices()) {
        if (service.getName().equals(current.getName())) {
          found = true;
        }
      }
      if (!found) {
        services.add(service);
      }
    }
    validateServiceDuplication(stackManager, stack, newExtension, services);
  }
An extension version is like a stack version but it contains custom services.  Linking an extension
version to the current stack version allows the cluster to install the custom services contained in
the extension version.
ambari-server/src/main/java/org/apache/ambari/server/stack/ExtensionHelper.java