Java Code Examples for io.siddhi.query.api.SiddhiApp#addQuery()
The following examples show how to use
io.siddhi.query.api.SiddhiApp#addQuery() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery106() throws InterruptedException { log.info("Filter test106"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.LONG).attribute ("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(100d)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50f, 60L, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 40L, 10}); inputHandler.send(new Object[]{"WSO2", 44f, 200L, 56}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); AssertJUnit.assertEquals(1, count.get()); siddhiAppRuntime.shutdown(); }
Example 2
Source File: FilterTestCase1.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery75() throws InterruptedException { log.info("Filter test75"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("quantity"), Compare.Operator.LESS_THAN_EQUAL, Expression.value(3L)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 500f, 60d, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 60d, 2}); inputHandler.send(new Object[]{"WSO2", 60f, 300d, 4}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); siddhiAppRuntime.shutdown(); }
Example 3
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery96() throws InterruptedException { log.info("Filter test96"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.DOUBLE).attribute("volume", Attribute.Type.DOUBLE); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(50)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50d, 60d}); inputHandler.send(new Object[]{"WSO2", 70d, 40d}); inputHandler.send(new Object[]{"WSO2", 44d, 200d}); SiddhiTestHelper.waitForEvents(10, 2, count, 100); AssertJUnit.assertEquals(2, count.get()); siddhiAppRuntime.shutdown(); }
Example 4
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery98() throws InterruptedException { log.info("Filter test98"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(60L)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 500f, 50d, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 60d, 2}); inputHandler.send(new Object[]{"WSO2", 50f, 300d, 4}); SiddhiTestHelper.waitForEvents(10, 2, count, 100); AssertJUnit.assertEquals(2, count.get()); siddhiAppRuntime.shutdown(); }
Example 5
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery94() throws InterruptedException { log.info("Filter test94"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(50d)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50f, 60d}); inputHandler.send(new Object[]{"WSO2", 70f, 40d}); inputHandler.send(new Object[]{"WSO2", 44f, 200d}); SiddhiTestHelper.waitForEvents(10, 2, count, 100); AssertJUnit.assertEquals(2, count.get()); siddhiAppRuntime.shutdown(); }
Example 6
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery103() throws InterruptedException { log.info("Filter test103"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("quantity"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(50d)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50f, 60d, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 40d, 10}); inputHandler.send(new Object[]{"WSO2", 44f, 200d, 56}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); AssertJUnit.assertEquals(1, count.get()); siddhiAppRuntime.shutdown(); }
Example 7
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery90() throws InterruptedException { log.info("Filter test90"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("quantity"), Compare.Operator.LESS_THAN, Expression.value(10f)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50f, 60d, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 40d, 10}); inputHandler.send(new Object[]{"WSO2", 44f, 200d, 56}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); AssertJUnit.assertEquals(1, count.get()); siddhiAppRuntime.shutdown(); }
Example 8
Source File: FilterTestCase1.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery69() throws InterruptedException { log.info("Filter test69"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.DOUBLE).attribute("volume", Attribute.Type.LONG); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.LESS_THAN_EQUAL, Expression.value(50)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50d, 60L}); inputHandler.send(new Object[]{"WSO2", 70d, 40L}); inputHandler.send(new Object[]{"WSO2", 44d, 200L}); SiddhiTestHelper.waitForEvents(10, 2, count, 100); siddhiAppRuntime.shutdown(); }
Example 9
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery104() throws InterruptedException { log.info("Filter test104"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("quantity"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(10f)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50f, 60d, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 40d, 10}); inputHandler.send(new Object[]{"WSO2", 44f, 200d, 56}); SiddhiTestHelper.waitForEvents(10, 2, count, 100); AssertJUnit.assertEquals(2, count.get()); siddhiAppRuntime.shutdown(); }
Example 10
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery87() throws InterruptedException { log.info("Filter test87"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.LESS_THAN, Expression.value(50d)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50f, 60d}); inputHandler.send(new Object[]{"WSO2", 70f, 40d}); inputHandler.send(new Object[]{"WSO2", 44f, 200d}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); AssertJUnit.assertEquals(1, count.get()); siddhiAppRuntime.shutdown(); }
Example 11
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery85() throws InterruptedException { log.info("Filter test85"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("quantity"), Compare.Operator.LESS_THAN, Expression.value(4L)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 500f, 50d, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 60d, 2}); inputHandler.send(new Object[]{"WSO2", 50f, 300d, 4}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); AssertJUnit.assertEquals(1, count.get()); siddhiAppRuntime.shutdown(); }
Example 12
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery84() throws InterruptedException { log.info("Filter test84"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.LESS_THAN, Expression.value(60L)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 500f, 50d, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 60d, 2}); inputHandler.send(new Object[]{"WSO2", 50f, 300d, 4}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); AssertJUnit.assertEquals(1, count.get()); siddhiAppRuntime.shutdown(); }
Example 13
Source File: FilterTestCase1.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery17() throws InterruptedException { log.info("Filter test17"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.LONG); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.GREATER_THAN, Expression.value(45)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("volume", Expression.variable("volume"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50f, 60L}); inputHandler.send(new Object[]{"WSO2", 70f, 40L}); inputHandler.send(new Object[]{"WSO2", 44f, 200L}); SiddhiTestHelper.waitForEvents(10, 2, count, 100); siddhiAppRuntime.shutdown(); }
Example 14
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery105() throws InterruptedException { log.info("Filter test105"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("quantity"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(15)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50f, 60d, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 40d, 10}); inputHandler.send(new Object[]{"WSO2", 44f, 200d, 56}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); AssertJUnit.assertEquals(1, count.get()); siddhiAppRuntime.shutdown(); }
Example 15
Source File: FilterTestCase1.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery72() throws InterruptedException { log.info("Filter test72"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.LESS_THAN_EQUAL, Expression.value(200L)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 500f, 60d, 5}); inputHandler.send(new Object[]{"WSO2", 70f, 60d, 2}); inputHandler.send(new Object[]{"WSO2", 60f, 300d, 4}); SiddhiTestHelper.waitForEvents(10, 2, count, 100); siddhiAppRuntime.shutdown(); }
Example 16
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testFilterQuery99() throws InterruptedException { log.info("Filter test99"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("quantity"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(4L)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price")).select("quantity", Expression.variable("quantity"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 500f, 50d, 6}); inputHandler.send(new Object[]{"WSO2", 70f, 60d, 2}); inputHandler.send(new Object[]{"WSO2", 50f, 300d, 4}); SiddhiTestHelper.waitForEvents(10, 2, count, 100); AssertJUnit.assertEquals(2, count.get()); siddhiAppRuntime.shutdown(); }
Example 17
Source File: FilterTestCase2.java From siddhi with Apache License 2.0 | 4 votes |
@Test public void testFilterQuery113() throws InterruptedException { log.info("Filter test113"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE) .attribute("quantity", Attribute.Type.INT).attribute("awards", Attribute.Type.LONG); Query query = new Query(); query.from(InputStream.stream("cseEventStream")); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select( Selector.selector(). select("symbol", Expression.variable("symbol")). select("modPrice", Expression.mod(Expression.variable("price"), Expression.value(2))). select("modVolume", Expression.mod(Expression.variable("volume"), Expression.value(2))). select("modQuantity", Expression.mod(Expression.variable("quantity"), Expression.value(2))). select("modAwards", Expression.mod(Expression.variable("awards"), Expression.value(2))) ); query.insertInto("OutputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); AssertJUnit.assertTrue("1.5".equals(inEvents[0].getData()[1].toString())); AssertJUnit.assertTrue("1.0".equals(inEvents[0].getData()[2].toString())); AssertJUnit.assertTrue("1".equals(inEvents[0].getData()[3].toString())); AssertJUnit.assertTrue("1".equals(inEvents[0].getData()[4].toString())); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 55.5f, 101d, 5, 7L}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); AssertJUnit.assertEquals(1, count.get()); siddhiAppRuntime.shutdown(); }
Example 18
Source File: FilterTestCase1.java From siddhi with Apache License 2.0 | 4 votes |
@Test public void testFilterQuery52() throws InterruptedException { log.info("Filter test52"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE); Query query = new Query(); query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.EQUAL, Expression.value(60)))); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression .variable("price"))); query.insertInto("outputStream"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 50f, 60d}); inputHandler.send(new Object[]{"WSO2", 70f, 40d}); inputHandler.send(new Object[]{"WSO2", 44f, 200d}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); siddhiAppRuntime.shutdown(); }
Example 19
Source File: FilterTestCase1.java From siddhi with Apache License 2.0 | 4 votes |
@Test public void testFilterQuery20() throws InterruptedException { log.info("Filter test20"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.LONG); Query query = new Query(); query.from(InputStream.stream("cseEventStream"). filter(Expression.compare(Expression.variable("volume"), Compare.Operator.LESS_THAN, Expression.value(100)) ) ); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select( Selector.selector(). select("symbol", Expression.variable("symbol")). select("price", Expression.variable("price")). select("volume", Expression.variable("volume")) ); query.insertInto("StockQuote"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); AssertJUnit.assertEquals(10L, ((Long) inEvents[0].getData(2)).longValue()); count.addAndGet(inEvents.length); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"WSO2", 55.6f, 103L}); inputHandler.send(new Object[]{"WSO2", 57.6f, 10L}); SiddhiTestHelper.waitForEvents(10, 1, count, 100); siddhiAppRuntime.shutdown(); }
Example 20
Source File: PassThroughTestCase.java From siddhi with Apache License 2.0 | 4 votes |
@Test public void passThroughTest1() throws InterruptedException { log.info("pass through test1"); SiddhiManager siddhiManager = new SiddhiManager(); StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.INT); Query query = new Query(); query.from(InputStream.stream("cseEventStream")); query.annotation(Annotation.annotation("info").element("name", "query1")); query.select( Selector.selector(). select("symbol", Expression.variable("symbol")). select("price", Expression.variable("price")) ); query.insertInto("StockQuote"); SiddhiApp siddhiApp = new SiddhiApp("ep1"); siddhiApp.defineStream(cseEventStream); siddhiApp.addQuery(query); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp); siddhiAppRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(inEvents); AssertJUnit.assertTrue("IBM".equals(inEvents[0].getData(0)) || "WSO2".equals(inEvents[0].getData(0))); count += inEvents.length; eventArrived.set(true); } }); InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream"); siddhiAppRuntime.start(); inputHandler.send(new Object[]{"IBM", 100}); inputHandler.send(new Object[]{"WSO2", 100}); SiddhiTestHelper.waitForEvents(10, eventArrived, 100); AssertJUnit.assertEquals(2, count); AssertJUnit.assertTrue(eventArrived.get()); siddhiAppRuntime.shutdown(); }