From 3305b7c93e102debbc7c2269d9e29ea37f983c8d Mon Sep 17 00:00:00 2001 From: Tharik Kanaka Date: Mon, 1 Feb 2016 13:05:09 +0530 Subject: [PATCH] Sample added for Siddhi event triggers --- modules/samples/artifacts/0119/ReadMe.txt | 5 ++ .../cronTriggeredSensorStreamLogger.xml | 9 ++++ .../periodicalTriggeredSensorStreamLogger.xml | 9 ++++ .../0119/eventsimulatorfiles/events.csv | 4 ++ .../events_streamConfiguration.xml | 24 ++++++++++ .../cronTriggeredSensorStream_1.0.0.json | 48 +++++++++++++++++++ .../org.wso2.event.sensor.stream_1.0.0.json | 44 +++++++++++++++++ ...periodicalTriggeredSensorStream_1.0.0.json | 48 +++++++++++++++++++ .../executionplans/ExecutionPlan.siddhiql | 30 ++++++++++++ 9 files changed, 221 insertions(+) create mode 100644 modules/samples/artifacts/0119/ReadMe.txt create mode 100644 modules/samples/artifacts/0119/eventpublishers/cronTriggeredSensorStreamLogger.xml create mode 100644 modules/samples/artifacts/0119/eventpublishers/periodicalTriggeredSensorStreamLogger.xml create mode 100644 modules/samples/artifacts/0119/eventsimulatorfiles/events.csv create mode 100644 modules/samples/artifacts/0119/eventsimulatorfiles/events_streamConfiguration.xml create mode 100644 modules/samples/artifacts/0119/eventstreams/cronTriggeredSensorStream_1.0.0.json create mode 100644 modules/samples/artifacts/0119/eventstreams/org.wso2.event.sensor.stream_1.0.0.json create mode 100644 modules/samples/artifacts/0119/eventstreams/periodicalTriggeredSensorStream_1.0.0.json create mode 100644 modules/samples/artifacts/0119/executionplans/ExecutionPlan.siddhiql diff --git a/modules/samples/artifacts/0119/ReadMe.txt b/modules/samples/artifacts/0119/ReadMe.txt new file mode 100644 index 00000000..72baa2bb --- /dev/null +++ b/modules/samples/artifacts/0119/ReadMe.txt @@ -0,0 +1,5 @@ +This sample uses +EventPublisher: logger + +Producers: event simulator +Consumers: console diff --git a/modules/samples/artifacts/0119/eventpublishers/cronTriggeredSensorStreamLogger.xml b/modules/samples/artifacts/0119/eventpublishers/cronTriggeredSensorStreamLogger.xml new file mode 100644 index 00000000..ff8125b2 --- /dev/null +++ b/modules/samples/artifacts/0119/eventpublishers/cronTriggeredSensorStreamLogger.xml @@ -0,0 +1,9 @@ + + + + + + cron + + diff --git a/modules/samples/artifacts/0119/eventpublishers/periodicalTriggeredSensorStreamLogger.xml b/modules/samples/artifacts/0119/eventpublishers/periodicalTriggeredSensorStreamLogger.xml new file mode 100644 index 00000000..409c1d2f --- /dev/null +++ b/modules/samples/artifacts/0119/eventpublishers/periodicalTriggeredSensorStreamLogger.xml @@ -0,0 +1,9 @@ + + + + + + periodical + + diff --git a/modules/samples/artifacts/0119/eventsimulatorfiles/events.csv b/modules/samples/artifacts/0119/eventsimulatorfiles/events.csv new file mode 100644 index 00000000..b3bf3f08 --- /dev/null +++ b/modules/samples/artifacts/0119/eventsimulatorfiles/events.csv @@ -0,0 +1,4 @@ +199008131245,false,100,temperature,23.45656,7.12324,100.34,23.4545 +199008131245,true,101,temperature,23.45656,7.12324,100.34,23.4545 +199008131245,false,103,temperature,23.45656,7.12324,100.34,23.4545 +199008131245,true,104,temperature,23.45656,7.12324,100.34,23.4545 diff --git a/modules/samples/artifacts/0119/eventsimulatorfiles/events_streamConfiguration.xml b/modules/samples/artifacts/0119/eventsimulatorfiles/events_streamConfiguration.xml new file mode 100644 index 00000000..6eed77fb --- /dev/null +++ b/modules/samples/artifacts/0119/eventsimulatorfiles/events_streamConfiguration.xml @@ -0,0 +1,24 @@ + + + + events.csv + org.wso2.event.sensor.stream:1.0.0 + , + 1000 + \ No newline at end of file diff --git a/modules/samples/artifacts/0119/eventstreams/cronTriggeredSensorStream_1.0.0.json b/modules/samples/artifacts/0119/eventstreams/cronTriggeredSensorStream_1.0.0.json new file mode 100644 index 00000000..7b9b3464 --- /dev/null +++ b/modules/samples/artifacts/0119/eventstreams/cronTriggeredSensorStream_1.0.0.json @@ -0,0 +1,48 @@ +{ + "name": "cronTriggeredSensorStream", + "version": "1.0.0", + "nickName": "", + "description": "", + "metaData": [ + { + "name": "timestamp", + "type": "LONG" + }, + { + "name": "isPowerSaverEnabled", + "type": "BOOL" + }, + { + "name": "sensorId", + "type": "INT" + }, + { + "name": "sensorName", + "type": "STRING" + } + ], + "correlationData": [ + { + "name": "longitude", + "type": "DOUBLE" + }, + { + "name": "latitude", + "type": "DOUBLE" + } + ], + "payloadData": [ + { + "name": "triggered_time", + "type": "LONG" + }, + { + "name": "humidity", + "type": "FLOAT" + }, + { + "name": "sensorValue", + "type": "DOUBLE" + } + ] +} \ No newline at end of file diff --git a/modules/samples/artifacts/0119/eventstreams/org.wso2.event.sensor.stream_1.0.0.json b/modules/samples/artifacts/0119/eventstreams/org.wso2.event.sensor.stream_1.0.0.json new file mode 100644 index 00000000..7f2096b8 --- /dev/null +++ b/modules/samples/artifacts/0119/eventstreams/org.wso2.event.sensor.stream_1.0.0.json @@ -0,0 +1,44 @@ +{ + "name": "org.wso2.event.sensor.stream", + "version": "1.0.0", + "nickName": "", + "description": "", + "metaData": [ + { + "name": "timestamp", + "type": "LONG" + }, + { + "name": "isPowerSaverEnabled", + "type": "BOOL" + }, + { + "name": "sensorId", + "type": "INT" + }, + { + "name": "sensorName", + "type": "STRING" + } + ], + "correlationData": [ + { + "name": "longitude", + "type": "DOUBLE" + }, + { + "name": "latitude", + "type": "DOUBLE" + } + ], + "payloadData": [ + { + "name": "humidity", + "type": "FLOAT" + }, + { + "name": "sensorValue", + "type": "DOUBLE" + } + ] +} \ No newline at end of file diff --git a/modules/samples/artifacts/0119/eventstreams/periodicalTriggeredSensorStream_1.0.0.json b/modules/samples/artifacts/0119/eventstreams/periodicalTriggeredSensorStream_1.0.0.json new file mode 100644 index 00000000..a02765eb --- /dev/null +++ b/modules/samples/artifacts/0119/eventstreams/periodicalTriggeredSensorStream_1.0.0.json @@ -0,0 +1,48 @@ +{ + "name": "periodicalTriggeredSensorStream", + "version": "1.0.0", + "nickName": "", + "description": "", + "metaData": [ + { + "name": "timestamp", + "type": "LONG" + }, + { + "name": "isPowerSaverEnabled", + "type": "BOOL" + }, + { + "name": "sensorId", + "type": "INT" + }, + { + "name": "sensorName", + "type": "STRING" + } + ], + "correlationData": [ + { + "name": "longitude", + "type": "DOUBLE" + }, + { + "name": "latitude", + "type": "DOUBLE" + } + ], + "payloadData": [ + { + "name": "triggered_time", + "type": "LONG" + }, + { + "name": "humidity", + "type": "FLOAT" + }, + { + "name": "sensorValue", + "type": "DOUBLE" + } + ] +} \ No newline at end of file diff --git a/modules/samples/artifacts/0119/executionplans/ExecutionPlan.siddhiql b/modules/samples/artifacts/0119/executionplans/ExecutionPlan.siddhiql new file mode 100644 index 00000000..8a9817f6 --- /dev/null +++ b/modules/samples/artifacts/0119/executionplans/ExecutionPlan.siddhiql @@ -0,0 +1,30 @@ +/* Enter a unique ExecutionPlan */ +@Plan:name('ExecutionPlan') + +/* Enter a unique description for ExecutionPlan */ +-- @Plan:description('ExecutionPlan') + +/* define streams/tables and write queries here ... */ + + +@Import('org.wso2.event.sensor.stream:1.0.0') +define stream sensorStream (meta_timestamp long, meta_isPowerSaverEnabled bool, meta_sensorId int, meta_sensorName string, correlation_longitude double, correlation_latitude double, humidity float, sensorValue double); + + +@Export('cronTriggeredSensorStream:1.0.0') +define stream cronTriggeredSensorStream (meta_timestamp long, meta_isPowerSaverEnabled bool, meta_sensorId int, meta_sensorName string, correlation_longitude double, correlation_latitude double, triggered_time long, humidity float, sensorValue double); + +@Export('periodicalTriggeredSensorStream:1.0.0') +define stream periodicalTriggeredSensorStream (meta_timestamp long, meta_isPowerSaverEnabled bool, meta_sensorId int, meta_sensorName string, correlation_longitude double, correlation_latitude double, triggered_time long, humidity float, sensorValue double); + +define trigger periodicalTriggerStream at every 5 sec ; + +define trigger cronTriggerStream at '*/10 * * * * ?' ; + +from periodicalTriggerStream join sensorStream#window.time(10 sec) +select meta_timestamp, meta_isPowerSaverEnabled, meta_sensorId, meta_sensorName, correlation_longitude, correlation_latitude, triggered_time, humidity, sensorValue +insert into periodicalTriggeredSensorStream; + +from cronTriggerStream join sensorStream#window.time(10 sec) +select meta_timestamp, meta_isPowerSaverEnabled, meta_sensorId, meta_sensorName, correlation_longitude, correlation_latitude, triggered_time, humidity, sensorValue +insert into cronTriggeredSensorStream; \ No newline at end of file