Class DisableFlag
- java.lang.Object
-
- org.apache.cassandra.db.guardrails.Guardrail
-
- org.apache.cassandra.db.guardrails.DisableFlag
-
public class DisableFlag extends Guardrail
A guardrail that completely disables the use of a particular feature.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 Summary
Constructors Constructor Description DisableFlag(java.lang.String name, java.util.function.Predicate<ClientState> disabled, java.lang.String what)Creates a newDisableFlagguardrail.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidensureEnabled(java.lang.String what, ClientState state)Aborts the operation if this guardrail is disabled.voidensureEnabled(ClientState state)Aborts the operation if this guardrail is disabled.
-
-
-
Constructor Detail
-
DisableFlag
public DisableFlag(java.lang.String name, java.util.function.Predicate<ClientState> disabled, java.lang.String what)Creates a newDisableFlagguardrail.- Parameters:
name- the identifying name of the guardraildisabled- aClientState-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 differentwhat.
-
-
Method Detail
-
ensureEnabled
public void ensureEnabled(@Nullable ClientState state)Aborts the operation if this guardrail is disabled.This must be called when the feature guarded by this guardrail is used to ensure such use is in fact allowed.
- 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.
-
ensureEnabled
public void ensureEnabled(java.lang.String what, @Nullable ClientState state)Aborts the operation if this guardrail is disabled.This must be called when the feature guarded by this guardrail is used to ensure such use is in fact allowed.
- Parameters:
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. Anullvalue 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.
-
-