public class DisableFlag extends Guardrail
Note that this guardrail only aborts operations (if the feature is disabled) so is only meant for query-based guardrails (we're happy to reject queries deemed dangerous, but we don't want to create a guardrail that breaks compaction for instance).
Constructor and Description |
---|
DisableFlag(java.lang.String name,
java.util.function.Predicate<ClientState> disabled,
java.lang.String what)
Creates a new
DisableFlag guardrail. |
Modifier and Type | Method and Description |
---|---|
void |
ensureEnabled(ClientState state)
Aborts the operation if this guardrail is disabled.
|
void |
ensureEnabled(java.lang.String what,
ClientState state)
Aborts the operation if this guardrail is disabled.
|
public DisableFlag(java.lang.String name, java.util.function.Predicate<ClientState> disabled, java.lang.String what)
DisableFlag
guardrail.name
- the identifying name of the guardraildisabled
- a ClientState
-based supplier of boolean indicating whether the feature guarded by this
guardrail must be disabled.what
- The feature that is guarded by this guardrail (for reporting in error messages),
ensureEnabled(String, ClientState)
can specify a different what
.public void ensureEnabled(@Nullable ClientState state)
This must be called when the feature guarded by this guardrail is used to ensure such use is in fact allowed.
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.public void ensureEnabled(java.lang.String what, @Nullable ClientState state)
This must be called when the feature guarded by this guardrail is used to ensure such use is in fact allowed.
what
- The feature that is guarded by this guardrail (for reporting in error messages).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, although it won't
throw any exception if the failure threshold is exceeded. 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.Copyright © 2009-2022 The Apache Software Foundation