Class Guardrail
java.lang.Object
org.apache.cassandra.db.guardrails.Guardrail
- Direct Known Subclasses:
EnableFlag,Predicates,Threshold,Values
General 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
FieldsModifier and TypeFieldDescriptionprotected static final NoSpamLoggerfinal StringA name identifying the guardrail (mainly for shipping with diagnostic events).final StringAn optional description of the reason for guarding the operation.protected static final String -
Method Summary
Modifier and TypeMethodDescriptionbooleanenabled()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(String message, String redactedMessage, ClientState state) protected voidfail(String message, ClientState state) protected voidprotected void
-
Field Details
-
logger
-
REDACTED
- See Also:
-
name
A name identifying the guardrail (mainly for shipping with diagnostic events). -
reason
An optional description of the reason for guarding the operation.
-
-
Method Details
-
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
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
-
warn
-
fail
-
fail
-