public abstract class Guardrail
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
protected static NoSpamLogger |
logger |
java.lang.String |
name
A name identifying the guardrail (mainly for shipping with diagnostic events).
|
protected static java.lang.String |
REDACTED |
Modifier and Type | Method and Description |
---|---|
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 specific
ClientState , such as compaction or other background processes. |
boolean |
enabled(ClientState state)
Checks whether this guardrail is enabled or not.
|
protected void |
fail(java.lang.String message,
ClientState state) |
protected void |
fail(java.lang.String message,
java.lang.String redactedMessage,
ClientState state) |
protected void |
warn(java.lang.String message) |
protected void |
warn(java.lang.String message,
java.lang.String redactedMessage) |
protected static final NoSpamLogger logger
protected static final java.lang.String REDACTED
public final java.lang.String name
public boolean enabled()
ClientState
, such as compaction or other background processes. Operations that
are associated to a ClientState
, such as CQL queries, should use enabled(ClientState)
.true
if this guardrail is enabled, false
otherwise.public boolean enabled(@Nullable ClientState state)
state
- the client state, used to skip the check if the query is internal or is done by a superuser.
A null
value means that the check should be done regardless of the query.true
if this guardrail is enabled, false
otherwise.protected void warn(java.lang.String message)
protected void warn(java.lang.String message, java.lang.String redactedMessage)
protected void fail(java.lang.String message, @Nullable ClientState state)
protected void fail(java.lang.String message, java.lang.String redactedMessage, @Nullable ClientState state)
Copyright © 2009- The Apache Software Foundation