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;
}
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);
}
}
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();
}
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();
}
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();
}
Aggregations