This section provides an overview of the design view of the Stream Processor Studio.
Accesing the Design View
To open the design view of the Stream Processor Studio:
- Start the Stream Processor Studio and log in with your credentials. For detailed instructions, see Stream Processor Studio Overview - Starting Stream Processor Studio.
- Click New and open a new Siddhi file, or click Open and open an existing Siddhi file.
- Click Design View to open the Design View.
The design view opens as shown in the example below. It consists of a grid to which you can drag and drop the Siddhi components represented by icons displayed in the left panel to design a Siddhi application.
Adding Siddhi components
To add a Siddhi component to the Siddhi application that you are creating/editing in the design view, click on the relevant icon in the left pane, and then drag and drop it to the grid as demonstrated in the example below.
Once you add a Siddhi component, you can configure it as required. To configure a Siddhi component, click the settings icon on the component. This opens a form with parameters related to the relevant component.
The following is the complete list of Siddhi components that you can add to the grid of the design view when you create a Siddhi application.
Stream
Icon | |
---|---|
Description | A stream represents a logical series of events ordered in time. For a detailed description of streams, see Siddhi Query Guide - Stream. |
Form | To configure the stream, click the settings icon on the stream component you added to the grid. Then enter values as follows: Stream Name : A unique name for the stream. This should be specified in title caps, and without spaces (e.g., Attributes: Attributes of streams are specified as name and type pairs in the Attributes table. |
Example | The details entered in the above form creates a stream configuration as follows: define stream SweetProductionStream (amount double, name string); |
Source |
|
Target |
|
Source
Icon | |
---|---|
Description | A source receives events in the specified transport and in the specified format. For more information, see Siddhi Query Guide - Source. |
Form | To configure the source, click the settings icon on the source component you added to the grid. This opens a form where you can enter the following information: To access the form in which you can configure a source, you must first connect the source as the source (input) object to a stream component.
|
Example | The details entered in the above form creates a source configuration as follows: @source(type = 'tcp', @map(type = 'json', @attributes(name = "$.sweet", amount = "$.batch.count"))) |
Source | No connection can start from another Siddhi component and link to a source because a source is the point from which events selected into the event flow of the Siddhi application start. |
Target | Streams |
Sink
Icon | |
---|---|
Description | A sink publishes events via the specified transport and in the specified format. For more information, see Siddhi Query Guide - Sink . |
Form | To configure the sink, click the settings icon on the sink component you added to the grid. To access the form in which you can configure a sink, you must first connect the sinke as the target object to a stream component.
|
Example | The details entered in the above form creates a sink configuration as follows: @sink(type = 'log', prefix = "Sweet Totals:") |
Source | Streams |
Target | N/A A sink cannot be followed by another Siddhi component because it represents the last stage of the event flow where the results of the processing carried out by the Siddhi application are communicated via the required interface. |
Table
Icon | |
---|---|
Description | A table is a stored version of an stream or a table of events. For more information, see Siddhi Query Guide - Table. |
Form | To configure the table, click the settings icon on the table component you added to the grid. Name : This field specifies unique name for the table. This should be specified in title caps, and without spaces (e.g., Attributes: Attributes of tables are specified as name and type pairs in the Attributes table. To add a new attribute, click +Attribute. Store Type: This specifies the specific database type in which you want to stopre data or whether the data is to be stored in-memory. Once the store type is selected, select an option to indicate whether the datastore needs to be defined inline, whether you want to use a datasource defined in the Annotations: This section allows you to specify the table attributes you want to use as the primary key and indexes via the |
Example | The details entered in the above form creates a table definition as follows: @store(type = 'rdbms', datasource = "SweetProductionDB") define table ShipmentDetails (name string, supplier string, amount double); |
Source |
|
Target |
|
Window
Icon | |
---|---|
Description | This icon represents a window definition that can be shared across multiple queries. For more information, see Siddhi Query Guide - (Defined) Window. |
Form | To configure the window, click the settings icon on the window component you added to the grid, and update the following information.
|
Example | The details entered in the above form creates a window definition as follows: define window FiveMinTempWindow (roomNo int, temp double) time(5 min) output all events; |
Source |
|
Target |
|
Trigger
Icon | |
---|---|
Description | A trigger allows you to generate events periodically. For more information, see Siddhi Query Guide - Trigger. |
Form | To configure the trigger, click the settings icon on the trigger component you added to the grid, and update the following information.
|
Example | The details entered in the above orm creates a trigger definition as follows: define trigger FiveMinTriggerStream at every 5 min; |
Source | N/A |
Target |
|
Aggregation
Icon | |
---|---|
Description | Incremental aggregation allows you to obtain aggregates in an incremental manner for a specified set of time periods. For more information, see Siddhi Query Guide - Incremental Aggregation. Before you add an aggregation: Make sure that you have already added the stream with the events to which the aggregation is applied is already defined. |
Form | To configure the aggregation, click the settings icon on the aggregation component you added to the grid, and update the following information.
|
Example | The details entered in the above form creates an aggregation definition as follows: define aggregation TradeAggregation from TradeStream select symbol, avg(price) as avgPrice, sum(price) as total group by symbol aggregate by timestamp every seconds...years; |
Source | N/A |
Target | Join queries |
Function
Icon | |
---|---|
Description | The function icon represents Script in Siddhi Query Language. It allows you to write functions in other programming languages and execute them within Siddhi queries. A function component in a Siddhi application is not connected to ther Siddhi components in the design UI. However, the configuration of one or more Query components can include a reference to it. |
Form | To configure the function, click the settings icon on the function component you added to the grid, and update the following information.
|
Example | The details entered in the above form creates a function definition as follows: define function concatFN[JAVASCRIPT] return string { var str1 = data[0]; var str2 = data[1]; var str3 = data[2]; var responce = str1 + str2 + str3; return responce; }; |
Projection Query
Icon | |
---|---|
Description | This icon represents a query to project the events in an input stream to an output stream. This invoves selectng the attributes to be included in the output, renaming attributes, introducing constant values, and using mathematical and/or logical expressions. For more information, see Siddhi Query Guide - Query Projection. |
Form | Once you connect the query to an input stream (source) and an output stream (target), you can configure it. To configure the projection query, click the settings icon on the projection query component you added to the grid, and update the following information.
|
Example | The details entered in the above form creates a query as follows: from TradeStream select symbol, avg(price) as averagePrice, sum(volume) as total insert all events into OutputStream; |
Source |
|
Target |
|
Filter Query
Icon | |
---|---|
Description | A filter query filters information in an input stream based on a given condition. For more information, see Siddhi Query Guide - Filters. |
Form | Once you connect the query to an input stream (source) and an output stream (target), you can configure it. To configure the filter query, click the settings icon on the filter query component you added to the grid, and update the following information.
|
Example | The details entered in the above form creates a query with a filter as follows: from TradeStream[sum(amount) > 10000] select symbol, avg(price) as averagePrice, sum(amount) as total insert all events into OutputStream; |
Source |
|
Target |
|
Window Query
Icon | |
---|---|
Description | Window queries include a window to select a subset of events to be processed based on a specific criterion. For more information, see Siddhi Query Guide - (Defined) Window. |
Form | Once you connect the query to an input stream (source) and an output stream (target), you can configure it. To configure the window query, click the settings icon on the window query component you added to the grid, and update the following information.
|
Example | The details entered in the above Query Configuration form creates a query with a window as follows: from TradeStream#window.time(1 month) select symbol, avg(price) as averagePrice, sum(amount) as total insert all events into OutputStream; |
Source | A window query can have only one source at a given time.
|
Target |
|
Join Query
Icon | |
---|---|
Description | A join query derives a combined result from two streams in real-time based on a specified condition. For more information, see Siddhi Query Guide - Join. |
Form | Once you connect two Siddhi components to the join query as sources and another Siddhi component as the target, you can configure the join query. To configure the join query, click the settings icon on the join query component you added to the grid and update the following information.
|
Example | A join query is configured as follows: from TempStream[temp > 30.0]#window.time(1 min) as T join RegulatorStream[isOn == false]#window.length(1) as R on T.roomNo == R.roomNo select T.roomNo, R.deviceID, 'start' as action insert into RegulatorActionStream; |
Source | A join query must always be connected to two sources, and at least one of them must be a defined stream/trigger/window.
|
Target | A join query must always be connected to a single target.
|
Pattern Query
Icon | |
---|---|
Description | A pattern query detects patterns in events that arrive overtime. For more information, see Siddhi Query Guide - Patterns. |
Form | Once you connect the query to an input stream (source) and an output stream (target), you can configure it. To configure the pattern query, click the settings icon on the pattern query component you added to the grid and update the following information.
|
Example | The above configuration results in creating the following query. from every (e1=MaterialSupplyStream) -> not MaterialConsumptionStream[name == e1.name and amount == e1.amount] for 15 sec select e1.name, e1.amount insert into ProductionDelayAlertStream; |
Source |
|
Target |
|
Sequence Query
Icon | |
---|---|
Description | A sequence query detects sequences in event occurrences over time. For more information, see Siddhi Query Guide - Sequence. |
Form | Once you connect the query to an input stream (source) and an output stream (target), you can configure it. To configure the sequence query, click the settings icon on the sequence query component you added to the grid and update the following information.
|
Example | The above configuration results in creating the following query. from every e1=SweetProductionStream, e2=SweetProductionStream[e1.amount > amount and (timestamp - e1.timestamp) < 10 * 60000]*, e3=SweetProductionStream[timestamp - e1.timestamp > 10 * 60000 and e1.amount > amount] select e1.name, e1.amount as initialAmount, e2.amount as finalAmount, e2.timestamp insert into DecreasingTrendAlertStream; |
Source |
|
Target |
|
Partitions
Icon | |
---|---|
Description | Before you add a partition: You need to add the stream to be partitioned. Partitions divide streams and queries into isolated groups in order to process them in parallel and in isolation. For more information, see Siddhi Query Guide - Partition. |
Form | Once the stream to be partitioned is connected as a source to the partition, you can configure the partition. In order to do so, move the cursor over the partition and click the settings icon on the partition component. This opens the Partition Configuration form. In this form, you can enter expressions to convert the attributes of the stream that is selected to be partitioned. |
Example | The above configuration creates the following partition query. partition with ( roomNo >= 1030 as 'serverRoom' or roomNo < 1030 and roomNo >= 330 as 'officeRoom' or roomNo < 330 as 'lobby' of TempStream) begin from TempStream#window.time(10 min) select roomNo, deviceID, avg(temp) as avgTemp insert into AreaTempStream end; |
Source | Streams |
Target | N/A |
Connecting Siddhi components
In order to define how the Siddhi components in a Siddhi application interact with each other to process events, you need to define connections between Siddhi components. A connection is defined by drawing an arrow from one component to another by dragging the cursor as demonstrated below.
Saving, running and debugging Siddhi applications
To save a Siddhi application that you created in the design view, you need to switch to the source view. You also need to switch to the source view to run or debug a Siddhi application. For more information, see the following sections: