Class Guardrail
- java.lang.Object
-
- org.apache.cassandra.db.guardrails.Guardrail
-
- Direct Known Subclasses:
DisableFlag,Predicates,Threshold,Values
public abstract class Guardrail extends java.lang.ObjectGeneral class defining a given guardrail that guards against some particular usage/condition.Some guardrails only emit warnings when triggered, while others abort the query that triggers them. Some may do one or the other based on specific threshold. The queries are aborted with an
InvalidRequestException.Note that all the defined classes support live updates, which is why each guardrail class constructor takes suppliers of the condition the guardrail acts on rather than the condition itself. This implies that said suppliers should be fast and non-blocking to avoid surprises.
-
-
Field Summary
Fields Modifier and Type Field Description protected static NoSpamLoggerloggerjava.lang.StringnameA name identifying the guardrail (mainly for shipping with diagnostic events).protected static java.lang.StringREDACTED
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanenabled()Checks whether this guardrail is enabled or not when the check is done for a background opperation that is not associated to a specificClientState, such as compaction or other background processes.booleanenabled(ClientState state)Checks whether this guardrail is enabled or not.protected voidfail(java.lang.String message, java.lang.String redactedMessage, ClientState state)protected voidfail(java.lang.String message, ClientState state)protected voidwarn(java.lang.String message)protected voidwarn(java.lang.String message, java.lang.String redactedMessage)
-
-
-
Field Detail
-
logger
protected static final NoSpamLogger logger
-
REDACTED
protected static final java.lang.String REDACTED
- See Also:
- Constant Field Values
-
name
public final java.lang.String name
A name identifying the guardrail (mainly for shipping with diagnostic events).
-
-
Method Detail
-
enabled
public boolean enabled()
Checks whether this guardrail is enabled or not when the check is done for a background opperation that is not associated to a specificClientState, such as compaction or other background processes. Operations that are associated to aClientState, such as CQL queries, should useenabled(ClientState).- Returns:
trueif this guardrail is enabled,falseotherwise.
-
enabled
public boolean enabled(@Nullable ClientState state)Checks whether this guardrail is enabled or not. This will be enabled if the database is initialized and the authenticated user (if specified) is not system nor superuser.- Parameters:
state- the client state, used to skip the check if the query is internal or is done by a superuser. Anullvalue means that the check should be done regardless of the query.- Returns:
trueif this guardrail is enabled,falseotherwise.
-
warn
protected void warn(java.lang.String message)
-
warn
protected void warn(java.lang.String message, java.lang.String redactedMessage)
-
fail
protected void fail(java.lang.String message, @Nullable ClientState state)
-
fail
protected void fail(java.lang.String message, java.lang.String redactedMessage, @Nullable ClientState state)
-
-