...
These 2 policies differ on the following: CreateTopicPolicy
includes all configurations, which allow validations between related configurations; but AlterConfigPolicy
only includes the configuration passed on the request, but not the existing configurations or configurations to delete.
This force users to a very limited type of validation (e.g. config x
cannot not be y
), when most important validations have a dependency between configurations (e.g. if value of a=b
and c=d
then x
cannot be y
). Even more, having these configuration available on creation, but not on alter means the effort put to validate on creation is wasted when altering.
...
Code Block |
---|
public interface AlterConfigPolicy extends Configurable, AutoCloseable { class RequestMetadata { private final ConfigResource resource; private final Map<String, String> proposedConfigs; private final Map<String,List<String> String>proposedConfigsToDelete; existingConfigs; private final List<String> deletedConfigsMap<String, String> existingConfigs; public RequestMetadata(ConfigResource resource, Map<String, String> proposedConfigs) { this.resource = resource; this.proposedConfigs = proposedConfigs; this.existingConfigs = Collections.emptyMap(); this.deletedConfigsproposedConfigsToDelete = Collections.emptyList(); } public RequestMetadata(ConfigResource resource, Map<String, String> proposedConfigs, List<String> proposedConfigsToDelete, Map<String, String> existingConfigs, List<String> deletedConfigs) { this.resource = resource; this.proposedConfigs = proposedConfigs; this.existingConfigs = existingConfigs; this.deletedConfigsproposedConfigsToDelete = deletedConfigsproposedConfigsToDelete; } // ... public Map<String, String> existingConfigsList<String> proposedConfigsToDelete() { return existingConfigsproposedConfigsToDelete; } public Map<String, public List<String> deletedConfigsString> existingConfigs() { return deletedConfigsexistingConfigs; } // ... void validate(RequestMetadata requestMetadata) throws PolicyViolationException; } |
...