Search in sources :

Example 6 with SimpleFunctionResolver

use of org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver 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 7 with SimpleFunctionResolver

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

the class DocCommandTest method setup.

@Before
public void setup() throws Exception {
    // setup the command
    command = new DocCommand();
    // setup a function resolver - only 3 functions have been defined
    SimpleFunctionResolver functionResolver = new SimpleFunctionResolver().withClass(StringFunctions.ToString.class).withClass(StringFunctions.ToLower.class).withClass(StringFunctions.ToUpper.class);
    // setup the executor
    Properties props = new Properties();
    executor = new DefaultStellarShellExecutor(functionResolver, props, Optional.empty());
    executor.init();
}
Also used : StringFunctions(org.apache.metron.stellar.dsl.functions.StringFunctions) SimpleFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver) Properties(java.util.Properties) DefaultStellarShellExecutor(org.apache.metron.stellar.common.shell.DefaultStellarShellExecutor) Before(org.junit.Before)

Aggregations

SimpleFunctionResolver (org.apache.metron.stellar.dsl.functions.resolver.SimpleFunctionResolver)7 Before (org.junit.Before)5 HashMap (java.util.HashMap)4 DefaultStellarStatefulExecutor (org.apache.metron.stellar.common.DefaultStellarStatefulExecutor)4 Properties (java.util.Properties)3 MockHBaseTableProvider (org.apache.metron.hbase.mock.MockHBaseTableProvider)2 GetProfile (org.apache.metron.profiler.client.stellar.GetProfile)2 ColumnBuilder (org.apache.metron.profiler.hbase.ColumnBuilder)2 RowKeyBuilder (org.apache.metron.profiler.hbase.RowKeyBuilder)2 SaltyRowKeyBuilder (org.apache.metron.profiler.hbase.SaltyRowKeyBuilder)2 ValueOnlyColumnBuilder (org.apache.metron.profiler.hbase.ValueOnlyColumnBuilder)2 DefaultStellarShellExecutor (org.apache.metron.stellar.common.shell.DefaultStellarShellExecutor)2 Context (org.apache.metron.stellar.dsl.Context)2 StringFunctions (org.apache.metron.stellar.dsl.functions.StringFunctions)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 HTableInterface (org.apache.hadoop.hbase.client.HTableInterface)1