Mmuzaf commented on code in PR #4263:
URL: https://github.com/apache/cassandra/pull/4263#discussion_r2223839403


##########
src/java/org/apache/cassandra/tools/nodetool/GuardrailsConfigCommand.java:
##########
@@ -112,89 +175,96 @@ public static class SetGuardrailsConfig extends 
GuardrailsConfigCommand
     {
         private static final Pattern SETTER_PATTERN = Pattern.compile("^set");
 
-        @Option(name = { "--list", "-l" },
-        description = "List all available guardrails setters")
-        private boolean list;
-
-        @Option(name = { "--category", "-c" },
-        description = "Category of guardrails to filter, can be one of 
'values', 'thresholds', 'flags', 'others'.",
-        allowedValues = { "values", "thresholds", "flags", "others" })
-        private String guardrailCategory;
-
         @Arguments(usage = "[<setter> <value1> ...]",
         description = "For flags, possible values are 'true' or 'false'. " +
-                      "For thresholds, two values are expected, first for 
warning, second for failure. " +
-                      "For values, one value is expected, multiple values 
separated by comma.")
+                      "For thresholds, two values are expected, first for 
failure, second for warning. " +
+                      "For values, enumeration of values expected or one value 
where multiple items are separated by comma. " +
+                      "Setting for thresholds accepting strings and value 
guardrails are reset by specifying 'null' value. " +
+                      "For thresholds accepting integers, the reset value is 
-1.")
         private final List<String> args = new ArrayList<>();
 
         @Override
         public void execute(NodeProbe probe)
         {
-            if (!list && guardrailCategory != null)
-                throw new IllegalStateException("--category/-c can be 
specified only together with --list/-l");
+            if (args.isEmpty())
+                throw new IllegalStateException("No arguments.");
 
-            GuardrailCategory categoryEnum = 
GuardrailCategory.parseCategory(guardrailCategory, probe.output().out);
+            String snakeCaseName = args.get(0);
 
-            if (args.isEmpty() && !list)
-                throw new IllegalStateException("No arguments.");
+            Method setter = getAllSetters(probe).entrySet().stream()
+                                                    .findFirst()
+                                                    .map(o -> 
o.getValue().get(0))
+                                                    .orElseThrow(() -> new 
IllegalStateException(format("Guardrail %s not found.", snakeCaseName)));
 
-            if (list)
-                display(probe, getAllSetters(probe), categoryEnum);
-            else
-                executeSetter(probe);
+            sanitizeArguments(setter, args);

Review Comment:
   A general question for the whole set command. 
   
   Assume that `read_consistency_levels_disallowed` was empty and we set it to 
"ANY", "ONE" with the following command:
   
   `"setguardrailsconfig", "read_consistency_levels_disallowed", "ANY", "ONE"`
   
   How to change it back to empty list? We have -1 for warn and fail for `int` 
values, but what about `Set<String>`?



-- 
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-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to