T
- The type of the values of which certain are warned, ignored and/or disallowed.public class Values<T> extends Guardrail
Constructor and Description |
---|
Values(java.lang.String name,
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.
|
Modifier and Type | Method and Description |
---|---|
void |
guard(java.util.Set<T> values,
ClientState state)
Triggers a warning for each of the provided values that is discouraged by this guardrail.
|
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.
|
public Values(java.lang.String name, 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)
name
- the identifying name of the guardrailwarnedValues
- a ClientState
-based provider of the values for which a warning is triggered.ignoredValues
- a ClientState
-based provider of the values that are ignored.disallowedValues
- a ClientState
-based provider of the values that are disallowed.what
- The feature that is guarded by this guardrail (for reporting in error messages).public void guard(java.util.Set<T> values, @Nullable ClientState state)
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.
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.
A null
value means that the check should be done regardless of the query.public void guard(java.util.Set<T> values, java.util.function.Consumer<T> ignoreAction, @Nullable ClientState state)
values
- The values to check.ignoreAction
- An action called on the subset of values
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.
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- The Apache Software Foundation