use of org.apache.metron.profiler.StandAloneProfiler in project metron by apache.
the class ProfilerFunctionsTest method testProfilerApplyWithMultipleMessagesInJSONString.
@Test
public void testProfilerApplyWithMultipleMessagesInJSONString() {
// initialize the profiler
state.put("config", helloWorldProfilerDef);
StandAloneProfiler profiler = run("PROFILER_INIT(config)", StandAloneProfiler.class);
state.put("profiler", profiler);
// apply a message to the profiler
state.put("messages", messages);
StandAloneProfiler result = run("PROFILER_APPLY(messages, profiler)", StandAloneProfiler.class);
// validate
assertSame(profiler, result);
assertEquals(1, profiler.getProfileCount());
assertEquals(3, profiler.getMessageCount());
assertEquals(3, profiler.getRouteCount());
}
use of org.apache.metron.profiler.StandAloneProfiler in project metron by apache.
the class ProfilerFunctionsTest method testProfilerInitWithProfiles.
@Test
public void testProfilerInitWithProfiles() {
state.put("config", helloWorldProfilerDef);
StandAloneProfiler profiler = run("PROFILER_INIT(config)", StandAloneProfiler.class);
assertNotNull(profiler);
assertEquals(1, profiler.getProfileCount());
assertEquals(0, profiler.getMessageCount());
assertEquals(0, profiler.getRouteCount());
}
use of org.apache.metron.profiler.StandAloneProfiler 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());
}
use of org.apache.metron.profiler.StandAloneProfiler in project metron by apache.
the class ProfilerFunctionsTest method testProfilerApplyWithListOfMessages.
@Test
public void testProfilerApplyWithListOfMessages() {
// initialize the profiler
state.put("config", helloWorldProfilerDef);
StandAloneProfiler profiler = run("PROFILER_INIT(config)", StandAloneProfiler.class);
state.put("profiler", profiler);
// apply a message to the profiler
state.put("msg", message);
StandAloneProfiler result = run("PROFILER_APPLY([msg, msg, msg], profiler)", StandAloneProfiler.class);
// validate
assertSame(profiler, result);
assertEquals(1, profiler.getProfileCount());
assertEquals(3, profiler.getMessageCount());
assertEquals(3, profiler.getRouteCount());
}
use of org.apache.metron.profiler.StandAloneProfiler in project metron by apache.
the class ProfilerFunctionsTest method testProfilerApplyWithNullMessage.
@Test(expected = IllegalArgumentException.class)
public void testProfilerApplyWithNullMessage() {
// initialize the profiler
state.put("config", helloWorldProfilerDef);
StandAloneProfiler profiler = run("PROFILER_INIT(config)", StandAloneProfiler.class);
state.put("profiler", profiler);
// there is no 'messages' variable - should throw exception
run("PROFILER_APPLY(messages, profiler)", StandAloneProfiler.class);
}
Aggregations