[ 
https://issues.apache.org/jira/browse/CASSANDRA-20249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17916928#comment-17916928
 ] 

Dmitry Konstantinov commented on CASSANDRA-20249:
-------------------------------------------------

An extra idea how to simplify reconciliation of the existing metrics: for 
properties in Config.java which are missed in cassandra.yaml the ticket they 
introduced can be found using the logic like this: get a line number for the 
property definition in Config.java, invoke git blame for this line, an example:
{code}
git blame -L485,+1 src/java/org/apache/cassandra/config/Config.java 
6422e34769e (Stefania Alborghetti 2015-06-22 15:35:03 +0800 485)     public 
double disk_optimization_estimate_percentile = 0.95;
{code}

> 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
>
>
> 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]

Reply via email to