Skip to content

Commit

Permalink
Merge pull request #408 from Meruja/samples
Browse files Browse the repository at this point in the history
samples reformatted
  • Loading branch information
mohanvive authored Dec 21, 2017
2 parents c7de647 + f3e4694 commit 73097ea
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 43 deletions.
10 changes: 5 additions & 5 deletions modules/samples/artifacts/HelloKafka/HelloKafka.siddhi
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ Viewing the Results:
group.id="group",
bootstrap.servers='localhost:9092',
@map(type='json'))
define stream StockStreamAsJSON(symbol string, price float, volume long);
define stream SweetProductionStream (name string, amount double);

@sink(type='kafka',
topic='kafka_result_topic',
bootstrap.servers='localhost:9092',
partition.no='0',
@map(type='xml'))
define stream StockStreamAsXML(symbol string, price float, totalVolume long);
define stream LowProductionAlertStream (name string, amount double);

--Send events in a length window of 5 from kafka_topic to kafka_result_topic
@info(name='query1')
from StockStreamAsJSON#window.length(5)
select symbol, price, volume as totalVolume
insert into StockStreamAsXML;
from SweetProductionStream#window.length(5)
select *
insert into LowProductionAlertStream;


6 changes: 3 additions & 3 deletions modules/samples/artifacts/HelloKafka/kafka_sample.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
WSO2,55.6,100
IBM,65.6,200
WSO2,75.6,300
chocolate,55.6
toffee,65.6
cake,75.6
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ define stream SweetProductionStream (name string, amount double);
bootstrap.servers='localhost:9092',
is.binary.message='true',
@map(type='binary'))
define stream LowProducitonAlertStream (name string, amount double);
define stream LowProductionAlertStream (name string, amount double);

@info(name='EventsPassthroughQuery')
from SweetProductionStream
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
@App:name('ReceiveEventsFromFile')
/*
Purpose:
This application demonstrates how to use siddhi-io-file for receiving.

Prerequisites:

1) Add relevant siddhi-io-file and siddhi-map-json jars to the {WSO2SPHome}/lib folder if not exist.
1) Add relevant 'siddhi-io-file' and 'siddhi-map-json' jars to the {WSO2SPHome}/lib folder if not exist.

2) If the sample is not running and producing output, do as following first.

2) If the sample is not running for the first time, do as following first.
- Move all the files in {WSO2SPHome}/samples/artifacts/ReceiveEventsFromFile/files/consumed directory to
{WSO2SPHome}/samples/artifacts/ReceiveEventsFromFile/files/new.
- Delete all the files in consumed and sink directories.
Expand All @@ -24,14 +26,17 @@ Executing the Sample:
2) If the Siddhi application starts successfully, the following messages would be shown on the console.
* ReceiveEventsFromFile.siddhi - Started Successfully!

3) Processed output events will be logged in the console.
3) Check the directories {WSO2SPHome}/samples/artifacts/ReceiveEventsFromFile/files/consumed and new.

4) Check the directories {WSO2SPHome}/samples/artifacts/ReceiveEventsFromFile/files/consumed and new.
4) All the files which were in the directory 'new' should have been moved to 'consumed' directory.

5) All the files which were in the directory 'new' should have been moved to 'consumed' directory.
Viewing the Results:
Processed output events will be logged in the console as follows:
INFO {org.wso2.siddhi.core.query.processor.stream.LogStreamProcessor} - ReceiveEventsFromFile: event, StreamEvent{ timestamp=1513847875990, beforeWindowData=null, onAfterWindowData=null, outputData=[apache, 80.0, 2.0], type=CURRENT, next=null}
INFO {org.wso2.siddhi.core.query.processor.stream.LogStreamProcessor} - ReceiveEventsFromFile: event, StreamEvent{ timestamp=1513847876004, beforeWindowData=null, onAfterWindowData=null, outputData=[cloudbees, 134.4, 2.0], type=CURRENT, next=null}
*/

@App:name('ReceiveEventsFromFile')

@source(type='file', mode='text.full',
dir.uri='file:/{WSO2SPHome}/samples/artifacts/ReceiveEventsFromFile/files/new',
action.after.process='move',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ Purpose:

Prerequisites:
1) Save this sample
"Siddhi App ReceiveMQTTInXMLFormat successfully deployed" message would be shown in the console
2) Before run this MQTT sample, set up mosquitto server which support mqtt
3) After the set up ,start the mosquitto server by running the following command
sudo service mosquitto start

Executing the Sample:
1) Start the Siddhi application by clicking on 'Run'.
2) "Siddhi App ReceiveMQTTInXMLFormat successfully deployed" message would be shown in the console
1) Start the Siddhi application by clicking on 'Run', the following messages would be shown on the console.
ReceiveMQTTInXMLFormat.siddhi - Started Successfully!

Testing the Sample:
Option1: Publish events with the command line publisher:
Open a terminal and publish events using following command. (The values for name and amount attributes can be changed as desired)
mosquitto_pub -t 'mqtt_topic_input' -m '<events><event><name>sugar</name><amount>300.0</amount></event></events>'

Option2: Publish events with mqtt sample client:
Run "ant" command in the terminal:
If you want to publish custom number of events, you need to run "ant" command as follows
Open a terminal and issue command from the {WSO2SPHome}/samples/sample-clients/mqtt-client and run 'ant' command.:
If you want to publish custom number of events, you need to run 'ant' command as follows:
ant -DnoOfEventsToSend=5

Viewing the Results:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Prerequisites:
sudo apt-get install rabbitmq-server
3) To enable RabbitMQ Management Console, run the following:
sudo rabbitmq-plugins enable rabbitmq_management
4) To start the service, issue the following command:
invoke-rc.d rabbitmq-server start

Executing the Sample:
1) Start the Siddhi application by clicking on 'Run'.
Expand All @@ -18,9 +20,9 @@ Executing the Sample:
Check whether the exchange 'rabbitmq_sample' is created in the rabbitmq server or not. To check that you can visit http://localhost:15672/

Testing the Sample:
Option1: Publish events with rabbitmq sample publisher:
Run "ant" command in the terminal
If you want to publish custom number of events, you need to run "ant" command as follows:
Publish events with rabbitmq sample publisher:
Open a terminal and issue command from the {WSO2SPHome}/samples/sample-clients/rabbitmq-producer and run 'ant' command.
If you want to publish custom number of events, you need to run 'ant' command as follows:
ant -DnoOfEventsToPublish=5

Viewing the Results:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Executing the Sample:
1) Start the Siddhi application by clicking on 'Run'.
2) If the Siddhi application starts successfully, the following messages would be shown on the console.
* Tcp Server started in 0.0.0.0:9892
* ReceiveTCPinBinaryFormat - Started Successfully!
* ReceiveTCPinTextFormat.siddhi - Started Successfully!

Testing the Sample:
1) Navigate to {WSO2SPHome}/samples/sample-clients/tcp-producer and run "ant" command as follows:
1) Navigate to {WSO2SPHome}/samples/sample-clients/tcp-client and run "ant" command as follows:
ant -Dtype=text
If you want to publish custom number of events, you need to run "ant" command as follows
ant -Dtype=text -DnoOfEventsToSend=5
Expand All @@ -30,11 +30,11 @@ Notes:

Viewing the Results:
See the output. Following messages would be shown on the console.
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProducitonAlertStream : Event{timestamp=1512990726372, data=[Eclair, 2171.0], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProducitonAlertStream : Event{timestamp=1512990727362, data=[Froyo, 1155.0], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProducitonAlertStream : Event{timestamp=1512990728363, data=[Gingerbread, 8840.0], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProducitonAlertStream : Event{timestamp=1512990729363, data=[Marshmallow, 7400.0], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProducitonAlertStream : Event{timestamp=1512990730364, data=[Cupcake, 889.0], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProductionAlertStream : Event{timestamp=1512990726372, data=[Eclair, 2171.0], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProductionAlertStream : Event{timestamp=1512990727362, data=[Froyo, 1155.0], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProductionAlertStream : Event{timestamp=1512990728363, data=[Gingerbread, 8840.0], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProductionAlertStream : Event{timestamp=1512990729363, data=[Marshmallow, 7400.0], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - ReceiveTCPinTextFormat : LowProductionAlertStream : Event{timestamp=1512990730364, data=[Cupcake, 889.0], isExpired=false}

*/

Expand All @@ -45,7 +45,7 @@ define stream SweetProductionStream (name string, amount double);
@sink(type='log')
define stream LowProductionAlertStream (name string, amount double);

-- passthrough data in the SweetProductionStream into LowProducitonAlertStream
-- passthrough data in the SweetProductionStream into LowProductionAlertStream
@info(name='query1')
from SweetProductionStream
select *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Testing the Sample:
Viewing the Results:
Viewing the Results:
Messages similar to the following would be shown on the console.
INFO {org.wso2.siddhi.core.query.processor.stream.LogStreamProcessor} - RegexExecutionSample: Event, StreamEvent{ timestamp=1513380672897, beforeWindowData=null, onAfterWindowData=null, outputData=[chocolate cake, true], type=CURRENT, next=null}
INFO {org.wso2.siddhi.core.query.processor.stream.LogStreamProcessor} - RegexExecutionSample: Event, StreamEvent{ timestamp=1513380739100, beforeWindowData=null, onAfterWindowData=null, outputData=[coffee cake, false], type=CURRENT, next=null}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - RegexExecutionSample : ChocolateProductStream : Event{timestamp=1513759840093, data=[Chocolate cake, true], isExpired=false}
INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - RegexExecutionSample : ChocolateProductStream : Event{timestamp=1513759907324, data=[Coffee cake, false], isExpired=false}

*/
define stream SweetProductionStream (name string, amount double);
Expand Down
18 changes: 14 additions & 4 deletions modules/samples/artifacts/ScriptJsSample/Script-js-sample.siddhi
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ Executing the Sample:
1) Start the Siddhi application by clicking on 'Run'.
2) If the Siddhi application starts successfully, the following messages would be shown on the console.
Script-js-sample.siddhi - Started Successfully!

Viewing the Results:
See the output on the console. Description of the raw material with the passed details are shown in the logger.

When using the simulator or sending events please send events to sweetProductionStream to see the result
Testing the Sample:
1) To open event simulator by clicking on the second icon or press Ctrl+Shift+I.
2) In the Single Simulation tab of the panel, select values as follows:
Siddhi App Name : Script-js-sample
Stream Name : SweetProductiontream
3) In the name field and amount fields, enter 'toffee', '45.25' respectively and then click Send to send the event.
4) Send some more events.

Viewing the Results:
*See the output on the console. Description of the raw material with the passed details are shown in the logger.You will get the output as follows:
[2017-12-20_14-26-03_120] INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - Script-js-sample : logStream : Event{timestamp=1513760163112, data=[toffee, 45.25, There are 45.25kg of toffee in the store], isExpired=false}

Notes:
If you need to edit this application while it is running, then Save -> Start.
*/

define stream sweetProductionStream (name string, amount double);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ Testing the Sample:


Viewing the Results:
Viewing the Results:
Messages similar to the following would be shown on the console.
INFO {org.wso2.siddhi.core.query.processor.stream.LogStreamProcessor} - StringExtensionSample: Event :, StreamEvent{ timestamp=1513378922227, beforeWindowData=null, onAfterWindowData=null, outputData=[cake], type=CURRENT, next=null}

INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - StringExtensionSample : OutputStream : Event{timestamp=1513760993921, data=[cake, 55.6], isExpired=false}
*/


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Executing the Sample:
1) Start the Siddhi application by clicking on 'Run'.
2) If the Siddhi application starts successfully, the following messages would be shown on the console.
* Tcp Server started in 0.0.0.0:9892
* Text-mapper-sample.siddhi - Started Successfully!
* TextMappingWithInmemoryTransport.siddhi - Started Successfully!

Testing the Sample:
Option1: Publish events with tcp sample client:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Executing the Sample:
Testing the Sample:
Navigate to {WSO2SPHome}/samples/sample-clients/http-client and run the following command
ant -Dtype=xml -DeventDefinition='<events><event><x>{0}</x><y>{1}</y></event></events>' -DfilePath={WSO2SPHome}/samples/artifacts/TimeExtensionSample/TimeSeries_events.txt -DnoOfEventsToSend=10 -DcontinuouslyReadFile=true
You can edit -DfilePath={WSO2SPHome}/samples/artifacts/timeSeriesExtensionSample/TimeSeries_events.txt -DnoOfEventsToSend=10 -DcontinuouslyReadFile=true file and give your own value set to check the lengthTimeRegress.
You can edit -DfilePath={WSO2SPHome}/samples/artifacts/TimeExtensionSample/TimeSeries_events.txt -DnoOfEventsToSend=10 -DcontinuouslyReadFile=true file and give your own value set to check the lengthTimeRegress.

Viewing the Results:
See the output on timeSeriesExtensionSample console.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ Viewing the Results:

*/

define stream InputStream (x double, y double);
define stream SweetProductionStream (name string, amount double);

@sink(type='log')
define stream WeightConvertedStream(name string, weightInGrams double);

from SweetProductionStream
select name, unitconversion:kgTog(weight) as weightInGrams
select name, unitconversion:kgTog(amount) as weightInGrams
insert into WeightConvertedStream;
2 changes: 2 additions & 0 deletions modules/samples/sample-clients/kafka-consumer/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
<include name="org.wso2.carbon.transport.http.netty_*.jar"/>
<include name="io.netty.*.jar"/>
<include name="commons-pool_*.jar"/>
<include name="org.apache.ws.commons.axiom.axiom-api_*.jar"/>
<include name="jaxen_*.jar"/>
</fileset>
</path>

Expand Down

0 comments on commit 73097ea

Please sign in to comment.