use of org.ballerinalang.siddhi.query.api.definition.TriggerDefinition in project ballerina by ballerina-lang.
the class TriggerTestCase method testQuery1.
@Test
public void testQuery1() throws InterruptedException {
log.info("testTrigger1 - OUT 0");
SiddhiManager siddhiManager = new SiddhiManager();
TriggerDefinition triggerDefinition = TriggerDefinition.id("cseEventStream").atEvery(Expression.Time.milliSec(500));
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineTrigger(triggerDefinition);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.shutdown();
}
use of org.ballerinalang.siddhi.query.api.definition.TriggerDefinition in project ballerina by ballerina-lang.
the class TriggerTestCase method testQuery2.
@Test(expectedExceptions = SiddhiAppValidationException.class)
public void testQuery2() throws InterruptedException {
log.info("testTrigger2 - OUT 0");
SiddhiManager siddhiManager = new SiddhiManager();
TriggerDefinition triggerDefinition = TriggerDefinition.id("cseEventStream").atEvery(Expression.Time.milliSec(500)).at("start");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineTrigger(triggerDefinition);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.shutdown();
}
use of org.ballerinalang.siddhi.query.api.definition.TriggerDefinition in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitDefinition_trigger.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Object visitDefinition_trigger(@NotNull SiddhiQLParser.Definition_triggerContext ctx) {
TriggerDefinition triggerDefinition = TriggerDefinition.id((String) visitTrigger_name(ctx.trigger_name()));
if (ctx.time_value() != null) {
triggerDefinition.atEvery(visitTime_value(ctx.time_value()).value());
} else {
triggerDefinition.at(visitString_value(ctx.string_value()).getValue());
}
populateQueryContext(triggerDefinition, ctx);
return triggerDefinition;
}
use of org.ballerinalang.siddhi.query.api.definition.TriggerDefinition in project ballerina by ballerina-lang.
the class SiddhiAppRuntimeBuilder method defineTrigger.
public void defineTrigger(TriggerDefinition triggerDefinition) {
DefinitionParserHelper.validateDefinition(triggerDefinition);
TriggerDefinition currentDefinition = triggerDefinitionMap.putIfAbsent(triggerDefinition.getId(), triggerDefinition);
if (currentDefinition != null) {
triggerDefinition = currentDefinition;
}
DefinitionParserHelper.addEventTrigger(triggerDefinition, triggerMap, streamJunctionMap, siddhiAppContext);
}
Aggregations