[
https://issues.apache.org/jira/browse/CASSANDRA-20249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17921404#comment-17921404
]
Stefan Miklosovic commented on CASSANDRA-20249:
-----------------------------------------------
We need to create a table and / or a PR where all properties would be added "as
if all of them are going to be there". And then we need to gather comments
where each such property would be documented. Then we need to figure out what
properties are going to be added into cassandra.yaml and which not. Feel free
to figure out better approach how to tackle this. My assumption is that people
who added these properties will be the ones who will know what it is for the
best so we just ask them to comment about that on the PR directly.
> Add a check if properties defined in Config.java but not mentioned in
> cassandra.yaml
> ------------------------------------------------------------------------------------
>
> Key: CASSANDRA-20249
> URL: https://issues.apache.org/jira/browse/CASSANDRA-20249
> Project: Apache Cassandra
> Issue Type: Task
> Components: Build
> Reporter: Dmitry Konstantinov
> Assignee: Dmitry Konstantinov
> Priority: Normal
> Attachments: config_discrepancy.txt
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Triggered by https://lists.apache.org/thread/ror3ynqthssf4yghq3o2hlbd9jyx8y0l
> It is quite frequent case when a new property is added to Config.java but not
> mentioned in cassandra.yaml and cassandra_latest.yaml. Sometimes, it is made
> intentionally for some non-public parameters.
> We need to find a way to detect such discrepancies between Config.java vs
> cassandra.yaml and cassandra_latest.yaml automatically.
> Intentionally hidden properties can be marked with some Java annotation in
> Config.java such as @Hidden
> A sketch of the check idea:
> {code}
> String configUrl = "file:///..cassandra-trunk/conf/cassandra.yaml";
> Field[] allFields = Config.class.getFields();
> List<String> topLevelPropertyNames = new ArrayList<>();
> for(Field field : allFields)
> {
> if (!Modifier.isStatic(field.getModifiers()))
> {
> topLevelPropertyNames.add(field.getName());
> }
> }
> URL url = new URL(configUrl);
> List<String> lines = Files.readAllLines(Paths.get(url.toURI()));
> int missedCount = 0;
> for (String propertyName : topLevelPropertyNames)
> {
> boolean found = false;
> for (String line : lines)
> {
> if (line.startsWith(propertyName + ":")
> || line.startsWith("#" + propertyName + ":")
> || line.startsWith("# " + propertyName + ":")) { //TODO: replace
> with a regexp to allow any number of spaces..
> found = true;
> break;
> }
> }
> if (!found)
> {
> missedCount++;
> System.out.println(propertyName);
> }
> }
> System.out.println("Total missed:" + missedCount);
> {code}
> Output example: [^config_discrepancy.txt]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]