Search in sources :

Example 1 with TriggerDefinition

use of io.siddhi.query.api.definition.TriggerDefinition in project siddhi by wso2.

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(io.siddhi.query.api.SiddhiApp) TriggerDefinition(io.siddhi.query.api.definition.TriggerDefinition) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) SiddhiManager(io.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 2 with TriggerDefinition

use of io.siddhi.query.api.definition.TriggerDefinition in project siddhi by wso2.

the class DefineTriggerTestCase method testTriggerDefinition.

@Test
public void testTriggerDefinition() {
    TriggerDefinition triggerDefinition = new TriggerDefinition();
    triggerDefinition.setQueryContextEndIndex(new int[1]);
    triggerDefinition.setQueryContextStartIndex(new int[1]);
    SiddhiApp.siddhiApp("test").defineTrigger(TriggerDefinition.id("TriggerStream").atEvery(Expression.Time.day(5).value()));
}
Also used : TriggerDefinition(io.siddhi.query.api.definition.TriggerDefinition) Test(org.testng.annotations.Test)

Example 3 with TriggerDefinition

use of io.siddhi.query.api.definition.TriggerDefinition in project siddhi by wso2.

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(io.siddhi.query.api.definition.TriggerDefinition)

Example 4 with TriggerDefinition

use of io.siddhi.query.api.definition.TriggerDefinition in project siddhi by wso2.

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(io.siddhi.query.api.definition.TriggerDefinition)

Example 5 with TriggerDefinition

use of io.siddhi.query.api.definition.TriggerDefinition in project siddhi by wso2.

the class DefineTriggerTestCase method testTriggerEventIdNull.

@Test(expectedExceptions = SiddhiAppValidationException.class)
public void testTriggerEventIdNull() {
    TriggerDefinition trigger = TriggerDefinition.id(null);
    SiddhiApp.siddhiApp("test").defineTrigger(trigger);
}
Also used : TriggerDefinition(io.siddhi.query.api.definition.TriggerDefinition) Test(org.testng.annotations.Test)

Aggregations

TriggerDefinition (io.siddhi.query.api.definition.TriggerDefinition)7 Test (org.testng.annotations.Test)5 SiddhiAppRuntime (io.siddhi.core.SiddhiAppRuntime)2 SiddhiManager (io.siddhi.core.SiddhiManager)2 SiddhiApp (io.siddhi.query.api.SiddhiApp)2