adelapena commented on code in PR #2649:
URL: https://github.com/apache/cassandra/pull/2649#discussion_r1317680570
##########
src/java/org/apache/cassandra/db/guardrails/EnableFlag.java:
##########
@@ -117,13 +117,33 @@ public void ensureEnabled(@Nullable ClientState state)
* want to interrupt such processes.
*/
public void ensureEnabled(String featureName, @Nullable ClientState state)
+ {
+ ensureEnabled(featureName, state, false);
+ }
+
+ /**
+ * Aborts the operation if this guardrail is not enabled.
+ *
+ * <p>This must be called when the feature guarded by this guardrail is
used to ensure such use is in fact
+ * allowed.
+ *
+ * @param featureName The feature that is guarded by this
guardrail (for reporting in error messages).
+ * @param state The client state, used to skip the check
if the query is internal or is done by a
+ * superuser. A {@code null} value means
that the check should be done regardless of
+ * the query, although it won't throw any
exception if the failure threshold isexceeded.
+ * This is so because checks without an
associated client come from asynchronous processes
+ * such as compaction, and we don't want to
interrupt such processes.
+ * @param throwOnNullClientState If this is true, an exception will be
thrown even if client state is null. This is
+ * mainly used for features not assoiate
with client state such as bulk load of SSTables.
+ */
+ public void ensureEnabled(String featureName, @Nullable ClientState state,
boolean throwOnNullClientState)
Review Comment:
I think this boolean flag shouldn't be added in an overload of
`ensureEnabled`, but set once with a method analogous to
`Guardrail#minNotifyIntervalInMs(long)`, probably
`Guardrail#throwOnNullClientState(boolen)`.
Same as `minNotifyIntervalInMs`, that method would be called once in the
`Guardrails` class, so it's defined once for the guardrail instance.
Adding that on the `Guardrail` class would have the benefit of working for
all its subclasses, without the need to modify them with additional method
overloads.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]