Search in sources :

Example 1 with StellarStatefulExecutor

use of org.apache.metron.stellar.common.StellarStatefulExecutor in project metron by apache.

the class ProfilerFunctionsTest method testProfilerInitWithNoGlobalConfig.

@Test
public void testProfilerInitWithNoGlobalConfig() {
    state.put("config", helloWorldProfilerDef);
    String expression = "PROFILER_INIT(config)";
    // use an executor with no GLOBAL_CONFIG defined in the context
    StellarStatefulExecutor executor = new DefaultStellarStatefulExecutor(new SimpleFunctionResolver().withClass(ProfilerFunctions.ProfilerInit.class).withClass(ProfilerFunctions.ProfilerApply.class).withClass(ProfilerFunctions.ProfilerFlush.class), Context.EMPTY_CONTEXT());
    StandAloneProfiler profiler = executor.execute(expression, state, StandAloneProfiler.class);
    assertNotNull(profiler);
    assertEquals(1, profiler.getProfileCount());
    assertEquals(0, profiler.getMessageCount());
    assertEquals(0, profiler.getRouteCount());
}
Also used : StandAloneProfiler(org.apache.metron.profiler.StandAloneProfiler) StellarStatefulExecutor(org.apache.metron.stellar.common.StellarStatefulExecutor) DefaultStellarStatefulExecutor(org.apache.metron.stellar.common.DefaultStellarStatefulExecutor) DefaultStellarStatefulExecutor(org.apache.metron.stellar.common.DefaultStellarStatefulExecutor) SimpleFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver) Test(org.junit.Test)

Example 2 with StellarStatefulExecutor

use of org.apache.metron.stellar.common.StellarStatefulExecutor in project metron by apache.

the class ProfilerFunctionsTest method testProfilerInitWithNoGlobalConfig.

@Test
public void testProfilerInitWithNoGlobalConfig() {
    state.put("config", helloWorldProfilerDef);
    String expression = "PROFILER_INIT(config)";
    // use an executor with no GLOBAL_CONFIG defined in the context
    StellarStatefulExecutor executor = new DefaultStellarStatefulExecutor(new SimpleFunctionResolver().withClass(ProfilerFunctions.ProfilerInit.class).withClass(ProfilerFunctions.ProfilerApply.class).withClass(ProfilerFunctions.ProfilerFlush.class), Context.EMPTY_CONTEXT());
    StandAloneProfiler profiler = executor.execute(expression, state, StandAloneProfiler.class);
    assertNotNull(profiler);
    assertEquals(1, profiler.getProfileCount());
    assertEquals(0, profiler.getMessageCount());
    assertEquals(0, profiler.getRouteCount());
}
Also used : StellarStatefulExecutor(org.apache.metron.stellar.common.StellarStatefulExecutor) DefaultStellarStatefulExecutor(org.apache.metron.stellar.common.DefaultStellarStatefulExecutor) DefaultStellarStatefulExecutor(org.apache.metron.stellar.common.DefaultStellarStatefulExecutor) SimpleFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultStellarStatefulExecutor (org.apache.metron.stellar.common.DefaultStellarStatefulExecutor)2 StellarStatefulExecutor (org.apache.metron.stellar.common.StellarStatefulExecutor)2 SimpleFunctionResolver (org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver)2 StandAloneProfiler (org.apache.metron.profiler.StandAloneProfiler)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1