Search in sources :

Example 1 with TriggerDefinition

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();
}
Also used : SiddhiApp(org.ballerinalang.siddhi.query.api.SiddhiApp) TriggerDefinition(org.ballerinalang.siddhi.query.api.definition.TriggerDefinition) SiddhiAppRuntime(org.ballerinalang.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.ballerinalang.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 2 with TriggerDefinition

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();
}
Also used : SiddhiApp(org.ballerinalang.siddhi.query.api.SiddhiApp) TriggerDefinition(org.ballerinalang.siddhi.query.api.definition.TriggerDefinition) SiddhiAppRuntime(org.ballerinalang.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.ballerinalang.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 3 with TriggerDefinition

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;
}
Also used : TriggerDefinition(org.ballerinalang.siddhi.query.api.definition.TriggerDefinition)

Example 4 with 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);
}
Also used : TriggerDefinition(org.ballerinalang.siddhi.query.api.definition.TriggerDefinition)

Aggregations

TriggerDefinition (org.ballerinalang.siddhi.query.api.definition.TriggerDefinition)4 SiddhiAppRuntime (org.ballerinalang.siddhi.core.SiddhiAppRuntime)2 SiddhiManager (org.ballerinalang.siddhi.core.SiddhiManager)2 SiddhiApp (org.ballerinalang.siddhi.query.api.SiddhiApp)2 Test (org.testng.annotations.Test)2