private void validateContentCluster(ChangeContext context, ContentCluster currentCluster, ContentCluster nextCluster) {
        String clusterName = currentCluster.getName();
        currentCluster.getDocumentDefinitions().forEach((documentTypeName, currentDocumentType) -> {
            NewDocumentType nextDocumentType = nextCluster.getDocumentDefinitions().get(documentTypeName);
            if (nextDocumentType != null) {
                boolean currentIsGlobal = currentCluster.isGloballyDistributed(currentDocumentType);
                boolean nextIsGlobal = nextCluster.isGloballyDistributed(nextDocumentType);
                boolean hosted = context.deployState().isHosted();
                if (currentIsGlobal != nextIsGlobal) {
                    String reason = "Document type %s in cluster %s changed global from %s to %s".formatted(documentTypeName, clusterName, currentIsGlobal, nextIsGlobal);
                    if ( ! context.deployState().validationOverrides().allows(ValidationId.globalDocumentChange, context.deployState().now())) {
                        if (! hosted)
                            reason = reason + "To handle this change, first stop services on all content nodes. Then, deploy with validation override. Finally, start services on all content nodes";
                        context.invalid(ValidationId.globalDocumentChange, reason);
                    } else if (hosted) {
                            reason = reason + "Content nodes will be restarted automatically";
                            context.require(new VespaRestartAction(ClusterSpec.Id.from(clusterName), reason,
                                                                   nextCluster.getSearch()
                                                                              .getSearchNodes()
                                                                              .stream()
                                                                              .map(AbstractService::getServiceInfo)
                                                                              .toList()));
                    }
                }
            }
        });
    }
Class that adds a validation failure if global attribute changes for a document
type in a content cluster unless corresponding override is present.
config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/GlobalDocumentChangeValidator.java