Build and Deploy Streaming Lite Project
- How to build a Streaming Lite project on HANA Studio
- How to deploy our project on
Raspberry Pi 2
Streaming Lite runs
.ccx files, which come from standard HANA Studio Streaming Analytics projects. We will be creating a streaming project called
"freezer_monitoring_lite" in HANA Studio. After creating and compiling the Streaming Analytics project, we will obtain a
.ccx file. This file is then uploaded to the
Raspberry Pi and run by Streaming Lite.
- Step 1
In HANA Studio, create a new HANA Streaming Analytics project called
"freezer_monitoring_lite", in the “default” workspace. For detailed instructions on creating a project, you can refer back to the Streaming Analytics: Run and Test a Streaming Project tutorial.
Copy the following
CCLcode into our
"freezer_monitoring_lite"project. Remember to delete the
NEWSTREAMelement that is created by default in each new project.sqlCopy
CREATE SCHEMA FreezerTemperatureReading ( SensorId string , Temperature float, ReadingDate msdate, Id long) ; CREATE INPUT STREAM isFreezerTemperatureReading SCHEMA FreezerTemperatureReading AUTOGENERATE ( Id ) ; /**@SIMPLEQUERY=AGGREGATE*/ CREATE OUTPUT WINDOW aAverageTemperatureBySensor PRIMARY KEY DEDUCED AS SELECT isFreezerTemperatureReading.SensorId MACHINEID , last (isFreezerTemperatureReading.ReadingDate) EVENT_TIME , 'TEMP'EVENT_NAME , '' EVENT_DESCRIPTION , string ( avg ( isFreezerTemperatureReading.Temperature ) ) EVENT_VALUE , count (isFreezerTemperatureReading.Temperature) rowct FROM isFreezerTemperatureReading KEEP EVERY 15 ROWS PER (SensorId) GROUP BY isFreezerTemperatureReading.SensorId ; /**@SIMPLEQUERY=FILTER*/ CREATE OUTPUT STREAM FilterEveryFifteenthRow AS SELECT aAverageTemperatureBySensor.MACHINEID, aAverageTemperatureBySensor.EVENT_TIME, aAverageTemperatureBySensor.EVENT_NAME, aAverageTemperatureBySensor.EVENT_DESCRIPTION, aAverageTemperatureBySensor.EVENT_VALUE FROM aAverageTemperatureBySensor WHERE aAverageTemperatureBySensor.rowct = 15 ;
The elements used in this project are:
Input stream for temperature sensor readings. In this tutorial, we will be using the
streaminguploadcommand line utility to write rows of data to this stream.
Incoming temperature values are grouped by
The average temperature is calculated for each
SensorIdbased on the temperature values currently in the window for the given
KEEP EVERY 15 ROWS PER (SensorId)policy specifies after receiving and processing the 15th value for a given
SensorId, all values for that
SensorIdare cleared from the window and the count is reset to 0. This behavior is referred to as a “jumping” window. If the
KEEPclause did not use the
EVERYkeyword, then it would be a sliding window in which the arrival of the
nthvalue would push out the
n-15thvalue. (The arrival of the 16th value would push out the 1st value, the 17th value would push out the 2nd value)
There is a counter to count the number of rows currently in the window
Maps the input schema into the schema that our SDS project
This filter allows a row through when the
aAverageTemperatureBySensorcounter equals 15 for a given
Result is that for every 15 rows that enter the project for a given
SensorId, one row is output from the filter for that
After creating our streaming project, compile it to generate the
.ccxfile. It will be located in the
bin/directory of our project folder.
For the question below, select the correct answer, and click Validate.
What file extension is obtained by compiling a Streaming Analytics project, that Streaming Lite runs?
- Step 2
Connect to your
WinSCP, and move your
.ccxfile over onto the
Pi. We are moving it into the
Run the Streaming Lite project using the command line. You can do this directly from a shell session on the
Pior remotely using Putty to open an SSH session. In either case you will run the following command line:BashCopy
$HOME/install/bin/streamingproject --ccx $HOME/freezer_monitoring_lite.ccx --command-port 9230
The first path points to
streamingproject, a binary executable from the Streaming Lite “install” folder. The second path points to the
freezer_monitoring_lite.ccxproject file. We then specify the port which our project will run on.
You should now see our Streaming Lite project running: