Search in sources :

Example 6 with QueryRuntime

use of io.siddhi.core.query.QueryRuntime in project siddhi by wso2.

the class SiddhiAppRuntimeImpl method debug.

public synchronized SiddhiDebugger debug() {
    siddhiDebugger = new SiddhiDebugger(siddhiAppContext);
    List<StreamRuntime> streamRuntime = new ArrayList<>();
    List<OutputCallback> streamCallbacks = new ArrayList<>();
    for (QueryRuntime queryRuntime : queryProcessorMap.values()) {
        streamRuntime.add(((QueryRuntimeImpl) queryRuntime).getStreamRuntime());
        streamCallbacks.add(((QueryRuntimeImpl) queryRuntime).getOutputCallback());
    }
    for (StreamRuntime streamRuntime1 : streamRuntime) {
        for (SingleStreamRuntime singleStreamRuntime : streamRuntime1.getSingleStreamRuntimes()) {
            singleStreamRuntime.getProcessStreamReceiver().setSiddhiDebugger(siddhiDebugger);
        }
    }
    for (OutputCallback callback : streamCallbacks) {
        callback.setSiddhiDebugger(siddhiDebugger);
    }
    start();
    return siddhiDebugger;
}
Also used : SiddhiDebugger(io.siddhi.core.debugger.SiddhiDebugger) OnDemandQueryRuntime(io.siddhi.core.query.OnDemandQueryRuntime) QueryRuntime(io.siddhi.core.query.QueryRuntime) SingleStreamRuntime(io.siddhi.core.query.input.stream.single.SingleStreamRuntime) ArrayList(java.util.ArrayList) StreamRuntime(io.siddhi.core.query.input.stream.StreamRuntime) SingleStreamRuntime(io.siddhi.core.query.input.stream.single.SingleStreamRuntime) OutputCallback(io.siddhi.core.query.output.callback.OutputCallback)

Example 7 with QueryRuntime

use of io.siddhi.core.query.QueryRuntime in project siddhi by wso2.

the class SiddhiAppRuntimeImpl method removeCallback.

public void removeCallback(QueryCallback callback) {
    if (callback.getQueryName() == null) {
        throw new SiddhiAppRuntimeException("Cannot find QueryName in the queryCallback");
    }
    String queryName = callback.getQueryName();
    QueryRuntime queryRuntime = queryProcessorMap.get(queryName);
    if (queryRuntime != null) {
        ((QueryRuntimeImpl) queryRuntime).removeCallback(callback);
    }
}
Also used : QueryRuntimeImpl(io.siddhi.core.query.QueryRuntimeImpl) OnDemandQueryRuntime(io.siddhi.core.query.OnDemandQueryRuntime) QueryRuntime(io.siddhi.core.query.QueryRuntime) SiddhiAppRuntimeException(io.siddhi.core.exception.SiddhiAppRuntimeException)

Example 8 with QueryRuntime

use of io.siddhi.core.query.QueryRuntime in project siddhi by wso2.

the class StateTestCase method stateTest2.

@Test
public void stateTest2() throws InterruptedException {
    log.info("stateTest2");
    SiddhiManager siddhiManager = new SiddhiManager();
    String app = "" + "define stream cseEventStream (symbol string, price float, volume int);" + "" + "partition with (symbol of cseEventStream) " + "begin " + "" + "   @info(name = 'query1') " + "   from cseEventStream " + "   select * " + "   insert all events into outputStream;" + "" + "   @info(name = 'query2') " + "   from cseEventStream#window.timeBatch(1 sec) " + "   select * " + "   insert all events into outputStream;" + "" + "   @info(name = 'query3') " + "   from cseEventStream " + "   select sum(price) as total " + "   insert all events into outputStream1;" + "" + "   @info(name = 'query4') " + "   from cseEventStream " + "   select * " + "   output every 5 min " + "   insert all events into outputStream;" + "" + "end " + "";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(app);
    for (QueryRuntime queryRuntime : siddhiAppRuntime.getPartitions().iterator().next().getQueries()) {
        inEventCount++;
        switch(inEventCount) {
            case 1:
                Assert.assertFalse(queryRuntime.isStateful());
                break;
            case 2:
                Assert.assertTrue(queryRuntime.isStateful());
                break;
            case 3:
                Assert.assertTrue(queryRuntime.isStateful());
                break;
            case 4:
                Assert.assertTrue(queryRuntime.isStateful());
                break;
        }
    }
    Assert.assertEquals(inEventCount, 4);
    siddhiAppRuntime.shutdown();
}
Also used : QueryRuntime(io.siddhi.core.query.QueryRuntime) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) SiddhiManager(io.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 9 with QueryRuntime

use of io.siddhi.core.query.QueryRuntime in project siddhi by wso2.

the class StateTestCase method stateTest1.

@Test
public void stateTest1() throws InterruptedException {
    log.info("stateTest1");
    SiddhiManager siddhiManager = new SiddhiManager();
    String app = "" + "define stream cseEventStream (symbol string, price float, volume int);" + "" + "@info(name = 'query1') " + "from cseEventStream " + "select * " + "insert all events into outputStream;" + "" + "@info(name = 'query2') " + "from cseEventStream#window.timeBatch(1 sec) " + "select * " + "insert all events into outputStream;" + "" + "@info(name = 'query3') " + "from cseEventStream " + "select sum(price) as total " + "insert all events into outputStream1;" + "" + "@info(name = 'query4') " + "from cseEventStream " + "select * " + "output every 5 min " + "insert all events into outputStream;" + "" + "";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(app);
    for (QueryRuntime queryRuntime : siddhiAppRuntime.getQueries()) {
        inEventCount++;
        switch(inEventCount) {
            case 1:
                Assert.assertFalse(queryRuntime.isStateful());
                break;
            case 2:
                Assert.assertTrue(queryRuntime.isStateful());
                break;
            case 3:
                Assert.assertTrue(queryRuntime.isStateful());
                break;
            case 4:
                Assert.assertTrue(queryRuntime.isStateful());
                break;
        }
    }
    Assert.assertEquals(inEventCount, 4);
    siddhiAppRuntime.shutdown();
}
Also used : QueryRuntime(io.siddhi.core.query.QueryRuntime) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) SiddhiManager(io.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 10 with QueryRuntime

use of io.siddhi.core.query.QueryRuntime in project siddhi by wso2.

the class StateTestCase method stateTest3.

@Test
public void stateTest3() throws InterruptedException {
    log.info("stateTest3");
    SiddhiManager siddhiManager = new SiddhiManager();
    String app = "" + "" + "define table cseEventTable (symbol string, price float, volume int);" + "" + "@Store(type='testStoreContainingInMemoryTable') " + "define table StockTable (symbol string, price float, volume long); " + "" + "define window cseEventWindow (symbol string, price float, volume int) time(1 sec) " + "       output all events; " + "" + "define trigger triggerStream at every 500 milliseconds ;" + "" + "define stream cseEventStream (symbol string, price float, volume int);" + "define stream twitterStream (user string, tweet string, company string); " + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "" + "@info(name = 'query1') " + "from cseEventStream#window.time(1 sec) join twitterStream#window.time(1 sec) " + "on cseEventStream.symbol== twitterStream.company " + "select cseEventStream.symbol as symbol, twitterStream.tweet, cseEventStream.price " + "insert all events into outputStream ;" + "" + "@info(name = 'query2') " + "from every ( e1=Stream1[price > 20] -> e2=Stream2[price > e1.price] " + "   or e3=Stream2['IBM' == symbol]) -> e4=Stream2[price > e1.price] " + "select e1.price as price1, e2.price as price2, e3.price as price3, e4.price as price4 " + "insert into OutputStream ;" + "";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(app);
    for (QueryRuntime queryRuntime : siddhiAppRuntime.getQueries()) {
        inEventCount++;
        switch(inEventCount) {
            case 1:
                Assert.assertTrue(queryRuntime.isStateful());
                break;
            case 2:
                Assert.assertTrue(queryRuntime.isStateful());
                break;
        }
    }
    for (Table table : siddhiAppRuntime.getTables()) {
        inEventCount++;
        switch(inEventCount) {
            case 3:
                Assert.assertTrue(table.isStateful());
                break;
            case 4:
                Assert.assertFalse(table.isStateful());
                break;
        }
    }
    inEventCount++;
    Assert.assertTrue(siddhiAppRuntime.getWindows().iterator().next().isStateful());
    inEventCount++;
    Assert.assertFalse(siddhiAppRuntime.getTiggers().iterator().next().isStateful());
    Assert.assertEquals(inEventCount, 6);
    siddhiAppRuntime.shutdown();
}
Also used : Table(io.siddhi.core.table.Table) QueryRuntime(io.siddhi.core.query.QueryRuntime) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) SiddhiManager(io.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Aggregations

QueryRuntime (io.siddhi.core.query.QueryRuntime)10 QueryRuntimeImpl (io.siddhi.core.query.QueryRuntimeImpl)5 StreamRuntime (io.siddhi.core.query.input.stream.StreamRuntime)4 SiddhiAppRuntime (io.siddhi.core.SiddhiAppRuntime)3 SiddhiManager (io.siddhi.core.SiddhiManager)3 OnDemandQueryRuntime (io.siddhi.core.query.OnDemandQueryRuntime)3 SingleStreamRuntime (io.siddhi.core.query.input.stream.single.SingleStreamRuntime)3 OutputCallback (io.siddhi.core.query.output.callback.OutputCallback)3 Test (org.testng.annotations.Test)3 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)2 StreamJunction (io.siddhi.core.stream.StreamJunction)2 Table (io.siddhi.core.table.Table)2 Map (java.util.Map)2 AggregationRuntime (io.siddhi.core.aggregation.AggregationRuntime)1 SiddhiAppContext (io.siddhi.core.config.SiddhiAppContext)1 SiddhiQueryContext (io.siddhi.core.config.SiddhiQueryContext)1 SiddhiDebugger (io.siddhi.core.debugger.SiddhiDebugger)1 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)1 StateEventPopulatorFactory (io.siddhi.core.event.state.populater.StateEventPopulatorFactory)1 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)1