private static void validateNotRequiredExtension(StackInfo stack, ExtensionInfo extension) throws AmbariException {
    for (ExtensionInfo stackExtension : stack.getExtensions()) {
      if (stackExtension != null) {
        for (ExtensionMetainfoXml.Extension requiredExtension : stackExtension.getExtensions()) {
          if (requiredExtension != null && requiredExtension.getName().equals(extension.getName())) {
            String message = "Stack extension is required by extension"
                        + ", stackName=" + stack.getName()
                        + ", stackVersion=" + stack.getVersion()
                        + ", extensionName=" + extension.getName()
                        + ", extensionVersion=" + extension.getVersion()
                        + ", dependentExtensionName=" + stackExtension.getName()
                        + ", dependentExtensionVersion=" + stackExtension.getVersion();

            throw new AmbariException(message);
          }
        }
      }
    }
  }
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