Search in sources :

Example 1 with PrecomputeFailure

use of org.graylog.plugins.pipelineprocessor.ast.exceptions.PrecomputeFailure in project graylog2-server by Graylog2.

the class Function method preprocessArgs.

default void preprocessArgs(FunctionArgs args) {
    for (Map.Entry<String, Expression> e : args.getConstantArgs().entrySet()) {
        final String name = e.getKey();
        try {
            final Object value = preComputeConstantArgument(args, name, e.getValue());
            if (value != null) {
                // noinspection unchecked
                final ParameterDescriptor<Object, Object> param = (ParameterDescriptor<Object, Object>) args.param(name);
                if (param == null) {
                    throw new IllegalStateException("Unknown parameter " + name + "! Cannot continue.");
                }
                args.setPreComputedValue(name, param.transform().apply(value));
            }
        } catch (Exception exception) {
            log.debug("Unable to precompute argument value for " + name, exception);
            throw new PrecomputeFailure(name, exception);
        }
    }
}
Also used : Expression(org.graylog.plugins.pipelineprocessor.ast.expressions.Expression) PrecomputeFailure(org.graylog.plugins.pipelineprocessor.ast.exceptions.PrecomputeFailure) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 PrecomputeFailure (org.graylog.plugins.pipelineprocessor.ast.exceptions.PrecomputeFailure)1 Expression (org.graylog.plugins.pipelineprocessor.ast.expressions.Expression)1