You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/03/09 18:55:03 UTC
[GitHub] [cassandra] adelapena commented on a change in pull request #1392: CASSANDRA-17188 trunk: Guardrails for consistency levels
adelapena commented on a change in pull request #1392:
URL: https://github.com/apache/cassandra/pull/1392#discussion_r822979477
##########
File path: src/java/org/apache/cassandra/db/guardrails/Guardrails.java
##########
@@ -415,13 +468,118 @@ public void setInSelectCartesianProductThreshold(int warn, int fail)
DEFAULT_CONFIG.setInSelectCartesianProductThreshold(warn, fail);
}
+ public Set<ConsistencyLevel> getReadConsistencyLevelsWarned()
+ {
+ return DEFAULT_CONFIG.getReadConsistencyLevelsWarned();
+ }
+
+ @Override
+ public String getReadConsistencyLevelsWarnedCSV()
+ {
+ return toCSV(DEFAULT_CONFIG.getReadConsistencyLevelsWarned(), ConsistencyLevel::toString);
+ }
+
+ @Override
+ public void setReadConsistencyLevelsWarned(Set<ConsistencyLevel> consistencyLevels)
+ {
+ DEFAULT_CONFIG.setReadConsistencyLevelsWarned(consistencyLevels);
+ }
+
+ @Override
+ public void setReadConsistencyLevelsWarnedCSV(String consistencyLevels)
+ {
+ DEFAULT_CONFIG.setReadConsistencyLevelsWarned(fromCSV(consistencyLevels, ConsistencyLevel::fromString));
+ }
+
+ @Override
+ public Set<ConsistencyLevel> getReadConsistencyLevelsDisallowed()
+ {
+ return DEFAULT_CONFIG.getReadConsistencyLevelsDisallowed();
+ }
+
+ @Override
+ public String getReadConsistencyLevelsDisallowedCSV()
+ {
+ return toCSV(DEFAULT_CONFIG.getReadConsistencyLevelsDisallowed(), ConsistencyLevel::toString);
+ }
+
+ @Override
+ public void setReadConsistencyLevelsDisallowed(Set<ConsistencyLevel> consistencyLevels)
+ {
+ DEFAULT_CONFIG.setReadConsistencyLevelsDisallowed(consistencyLevels);
+ }
+
+ @Override
+ public void setReadConsistencyLevelsDisallowedCSV(String consistencyLevels)
+ {
+ DEFAULT_CONFIG.setReadConsistencyLevelsDisallowed(fromCSV(consistencyLevels, ConsistencyLevel::fromString));
+ }
+
+ @Override
+ public Set<ConsistencyLevel> getWriteConsistencyLevelsWarned()
+ {
+ return DEFAULT_CONFIG.getWriteConsistencyLevelsWarned();
+ }
+
+ @Override
+ public String getWriteConsistencyLevelsWarnedCSV()
+ {
+ return toCSV(DEFAULT_CONFIG.getWriteConsistencyLevelsWarned(), ConsistencyLevel::toString);
+ }
+
+ @Override
+ public void setWriteConsistencyLevelsWarned(Set<ConsistencyLevel> consistencyLevels)
+ {
+ DEFAULT_CONFIG.setWriteConsistencyLevelsWarned(consistencyLevels);
+ }
+
+ @Override
+ public void setWriteConsistencyLevelsWarnedCSV(String consistencyLevels)
+ {
+ DEFAULT_CONFIG.setWriteConsistencyLevelsWarned(fromCSV(consistencyLevels, ConsistencyLevel::fromString));
+ }
+
+ @Override
+ public Set<ConsistencyLevel> getWriteConsistencyLevelsDisallowed()
+ {
+ return DEFAULT_CONFIG.getWriteConsistencyLevelsDisallowed();
+ }
+
+ @Override
+ public String getWriteConsistencyLevelsDisallowedCSV()
+ {
+ return toCSV(DEFAULT_CONFIG.getWriteConsistencyLevelsDisallowed(), ConsistencyLevel::toString);
+ }
+
+ @Override
+ public void setWriteConsistencyLevelsDisallowed(Set<ConsistencyLevel> consistencyLevels)
+ {
+ DEFAULT_CONFIG.setWriteConsistencyLevelsDisallowed(consistencyLevels);
+ }
+
+ @Override
+ public void setWriteConsistencyLevelsDisallowedCSV(String consistencyLevels)
+ {
+ DEFAULT_CONFIG.setWriteConsistencyLevelsDisallowed(fromCSV(consistencyLevels, ConsistencyLevel::fromString));
+ }
+
Review comment:
`CONFIG_PROVIDER` is used to get the actual config that is going to be used by the guardrails. This config can depend on the user if there is a custom implementation. If such custom implementation doesn't exist, then the default config would be the one defined in `cassandra.yaml`, which is accessed through either `DEFAULT_CONFIG` or `DatabaseDescriptor.getGuardrailsConfig()`.
However, `CONFIG_PROVIDER.getOrCreate(null)` doesn't necessarily return `DEFAULT_CONFIG`, since a custom implementation of the config provider can return something different, while `DEFAULT_CONFIG` is always the configuration defined in `cassandra.yaml`.
As for the JMX setters/getters, they are meant to exclusively change the default configuration defined in `cassandra.yaml`, which is accessible through either `DEFAULT_CONFIG` or `DatabaseDescriptor.getGuardrailsConfig()`. Indeed, the `GuardrailsConfig` interface doesn't even have setters. Any custom implementation interested on similar JMX getters/setters should provide its own mbeans, since the ones defined on `GuardrailsMBean` are only for the default config.
This is done this way to keep the JMX methods in `GuardrailsMBean` independent of guardrail config pluggability in general, and of `ClientState` in particular. This is so partly because that pluggability mechanism is not yet officially supported. This was agreed on CASSANDRA-17147.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org