Class 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 Detail

      • DisableFlag

        public DisableFlag​(java.lang.String name,
                           java.util.function.Predicate<ClientState> disabled,
                           java.lang.String what)
        Creates a new DisableFlag guardrail.
        Parameters:
        name - the identifying name of the guardrail
        disabled - 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.
    • 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. A null value 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. 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.