Class Values<T>
- java.lang.Object
-
- org.apache.cassandra.db.guardrails.Guardrail
-
- org.apache.cassandra.db.guardrails.Values<T>
-
- Type Parameters:
T
- The type of the values of which certain are warned, ignored and/or disallowed.
public class Values<T> extends Guardrail
A guardrail that warns about some specific values, warns about but ignores some other values, and/or rejects the use of some other values.
-
-
Constructor Summary
Constructors Constructor Description Values(java.lang.String name, java.lang.String reason, java.util.function.Function<ClientState,java.util.Set<T>> warnedValues, java.util.function.Function<ClientState,java.util.Set<T>> ignoredValues, java.util.function.Function<ClientState,java.util.Set<T>> disallowedValues, java.lang.String what)
Creates a new values guardrail.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
guard(java.util.Set<T> values, java.util.function.Consumer<T> ignoreAction, ClientState state)
Triggers a warning for each of the provided values that is discouraged by this guardrail.void
guard(java.util.Set<T> values, ClientState state)
Triggers a warning for each of the provided values that is discouraged by this guardrail.
-
-
-
Constructor Detail
-
Values
public Values(java.lang.String name, @Nullable java.lang.String reason, java.util.function.Function<ClientState,java.util.Set<T>> warnedValues, java.util.function.Function<ClientState,java.util.Set<T>> ignoredValues, java.util.function.Function<ClientState,java.util.Set<T>> disallowedValues, java.lang.String what)
Creates a new values guardrail.- Parameters:
name
- the identifying name of the guardrailreason
- the optional description of the reason for guarding the operationwarnedValues
- aClientState
-based provider of the values for which a warning is triggered.ignoredValues
- aClientState
-based provider of the values that are ignored.disallowedValues
- aClientState
-based provider of the values that are disallowed.what
- The feature that is guarded by this guardrail (for reporting in error messages).
-
-
Method Detail
-
guard
public void guard(java.util.Set<T> values, @Nullable ClientState state)
Triggers a warning for each of the provided values that is discouraged by this guardrail. If any of the values is disallowed it will abort the operation.This assumes that there aren't any values to be ignored, thus it doesn't require an ignore action. If this is not the case and the provided value is set up to be ignored this will throw an assertion error.
- Parameters:
values
- The values to check.state
- The client state, used to skip the check if the query is internal or is done by a superuser. Anull
value means that the check should be done regardless of the query.
-
guard
public void guard(java.util.Set<T> values, java.util.function.Consumer<T> ignoreAction, @Nullable ClientState state)
Triggers a warning for each of the provided values that is discouraged by this guardrail. Also triggers a warning for each of the provided values that is ignored by this guardrail and triggers the provided action to ignore it. If any of the values is disallowed it will abort the operation.- Parameters:
values
- The values to check.ignoreAction
- An action called on the subset ofvalues
that should be ignored. This action should do whatever is necessary to make sure the value is ignored.state
- The client state, used to skip the check if the query is internal or is done by a superuser. Anull
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.
-
-