Search in sources :

Example 1 with FunctionResolver

use of org.apache.metron.stellar.dsl.functions.resolver.FunctionResolver in project metron by apache.

the class KafkaFunctionsIntegrationTest method run.

/**
 * Runs a Stellar expression.
 * @param expression The expression to run.
 */
private Object run(String expression) {
    // make the global properties available to the function
    Context context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG, () -> global).build();
    // execute the expression
    StellarProcessor processor = new StellarProcessor();
    return processor.parse(expression, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), functionResolver, context);
}
Also used : Context(org.apache.metron.stellar.dsl.Context) StellarProcessor(org.apache.metron.stellar.common.StellarProcessor) ComponentRunner(org.apache.metron.integration.ComponentRunner) FunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.FunctionResolver) java.util(java.util) StellarProcessor(org.apache.metron.stellar.common.StellarProcessor) DefaultVariableResolver(org.apache.metron.stellar.dsl.DefaultVariableResolver) KafkaComponent(org.apache.metron.integration.components.KafkaComponent) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) Future(java.util.concurrent.Future) BaseIntegrationTest(org.apache.metron.integration.BaseIntegrationTest) org.junit.jupiter.api(org.junit.jupiter.api) ZKServerComponent(org.apache.metron.integration.components.ZKServerComponent) Assertions(org.junit.jupiter.api.Assertions) MapFunctions(org.apache.metron.stellar.dsl.functions.MapFunctions) SimpleFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver) ExecutorService(java.util.concurrent.ExecutorService) Context(org.apache.metron.stellar.dsl.Context) DefaultVariableResolver(org.apache.metron.stellar.dsl.DefaultVariableResolver)

Aggregations

java.util (java.util)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 Future (java.util.concurrent.Future)1 TimeUnit (java.util.concurrent.TimeUnit)1 BaseIntegrationTest (org.apache.metron.integration.BaseIntegrationTest)1 ComponentRunner (org.apache.metron.integration.ComponentRunner)1 KafkaComponent (org.apache.metron.integration.components.KafkaComponent)1 ZKServerComponent (org.apache.metron.integration.components.ZKServerComponent)1 StellarProcessor (org.apache.metron.stellar.common.StellarProcessor)1 Context (org.apache.metron.stellar.dsl.Context)1 DefaultVariableResolver (org.apache.metron.stellar.dsl.DefaultVariableResolver)1 MapFunctions (org.apache.metron.stellar.dsl.functions.MapFunctions)1 FunctionResolver (org.apache.metron.stellar.dsl.functions.resolver.FunctionResolver)1 SimpleFunctionResolver (org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver)1 org.junit.jupiter.api (org.junit.jupiter.api)1 Assertions (org.junit.jupiter.api.Assertions)1