Dmitry Konstantinov created CASSANDRA-20249:
-----------------------------------------------

             Summary: Add a check what 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
         Attachments: config_discrepancy.txt

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.

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 + ":")) {
            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]

Reply via email to