New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CASSANDRA-17797 All system properties and environment variables must be accessed via CassandraRelevantProperties #2046
Conversation
301af24
to
30ac4b5
Compare
src/java/org/apache/cassandra/db/ExpirationDateOverflowHandling.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentReader.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyOptions.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyOptions.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/service/paxos/uncommitted/PaxosStateTracker.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/service/paxos/uncommitted/PaxosStateTracker.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/service/reads/repair/BlockingReadRepairs.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/streaming/async/StreamingMultiplexedChannel.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/guardrails/GuardrailsConfigProvider.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/service/reads/repair/BlockingReadRepairs.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/utils/DiagnosticSnapshotService.java
Outdated
Show resolved
Hide resolved
test/distributed/org/apache/cassandra/distributed/test/PartitionDenylistTest.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyOptions.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job. I left some comments, mostly minor suggestions.
One more general idea is to have all those get/set methods in an interface as defaults and inherit them in CassandraRelevantProperties and the env counterpart
return InetAddressAndPort.getByName(System.getProperty(Config.PROPERTY_PREFIX + "replace_address", null)); | ||
else if (System.getProperty(Config.PROPERTY_PREFIX + "replace_address_first_boot", null) != null) | ||
return InetAddressAndPort.getByName(System.getProperty(Config.PROPERTY_PREFIX + "replace_address_first_boot", null)); | ||
String replaceAddress = REPLACE_ADDRESS.getString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you add a method Optional<String> getStringOpt()
, such snippets could be largely simplified, like:
return REPLACE_ADDRESS.getStringOpt()
.orElseGet(REPLACE_ADDRESS_FIRST_BOOT::getStringOpt)
.map(InetAddressAndPort::getByName)
.orElse(null);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 if it does the same thing.
test/unit/org/apache/cassandra/io/sstable/indexsummary/IndexSummaryTest.java
Show resolved
Hide resolved
test/unit/org/apache/cassandra/service/paxos/uncommitted/PaxosStateTrackerTest.java
Outdated
Show resolved
Hide resolved
test/distributed/org/apache/cassandra/distributed/shared/WithProperties.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general note to this file, I think we should:
- remove redundant defaults, like
null
,false
(maybe fail if such default is defined) - maybe fail if a default is defined for non-cassandra property - can we really assume such default?
- perhaps have overloaded set() method rather than setString, setInt, setLong, etc.
- have additional methods to get as optional
- have methods to check if is unset or default
- maybe have some methods to get values as
DataStorageSpec
andDurationSpec
objects - have some static initializer which asserts there are no duplicates
- rename enums so that they reflect the area of application
- rename some pure test properties which lacks reasonable prefix
- sort items
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these are relevant to implement but I would really focus on moving it all to CRP first and then we can optimize in other tickets. Or we may spend more time on this, sure ... depends how tasteful it will be for Maxim to chew through that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those are simple modifications, which can be significantly aided with IDE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacek-lewandowski Thanks for the comments.
At the first glance, I think we can fix most of them. Please keep in mind that due to the number of changed files in the patch, any additional changes other than a simple move to CRP will increase the time it takes to review and make conflict resolution a bit more difficult while we are still waiting for the patch to be reviewed. So the idea (as I understand the goal) is only do moves :-)
For example, you're right about sorting enum names (newly added names are sorted), but not all of them in the class. My mistake.
One important thing I'd like to mention:
We can't move all the defaults to CRP, especially those that are get calculated e.g. Gossiper.intervalInMillis * 2
it may trigger unnecessary classloading due to static variables being used, but moving the simple constant values is good if it makes sense for the subsystem. So, checking for a 'default' value might be a bit confusing for the cases where this default value is not present in CRP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mmuzaf regarding defaults - I agree. What I mean was actually that we should forbid defaults in CRP in two cases:
- this is not a Cassandra specific property - the rationale is that it can be misleading and hard to track - for example, imagine a netty property which is obviously defined in CRP. We have no idea what default the relevant component (like Netty) assumed. Moreover it may change with a new component version I doubt anybody will ever track that. In other words, non Cassandra-specific properties are defined in CRP to be set rather than read, so defaults for them are confusing. Maybe even reading from them should be forbidden? IDK
- the default value is the default default value :D, like null, false, 0
I don't think you need more reviews. If you put each IDE-aided refactoring in a distinct commit, we will not have to go through all the changes.
@Mmuzaf please don't force push and apply changes in separate commits; you will rebase once we finish the review phase |
Doesn't this go against our code style. We don't add get/set methods if there's not a reason to do so, and we don't add interfaces unless there's a reason to do so. |
I'm not suggesting adding any new methods, just moving the existing methods to the interface because they can not go to a superclass (enums). The only difference between |
src/java/org/apache/cassandra/db/compaction/CompactionController.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/service/paxos/uncommitted/PaxosStateTrackerTest.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/config/CassandraRelevantProperties.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's finish it, please just create follow-up tickets for the remaining stuff. Maybe create an epic and collect everything under it.
…Properties and CassandraRelevantEnv respectively
Committed: f650908 |
Thanks for sending a pull request! Here are some tips if you're new here:
Commit messages should follow the following format:
The Cassandra Jira