Adding a Streaming Web Service Output Adapter to Streaming Lite
This tutorial will explain how to send output data from a Streaming Lite project into a Smart Data Streaming project, using the SWS Output Adapter and the Streaming Web Service (SWS).
We will be taking a pre-existing Streaming Lite project called “freezer_monitoring_lite”, and adding a SWS Output adapter to it. We will then show the flow of data from Streaming Lite into our pre-existing Smart Data Streaming project called “freezer_monitoring”.
The Streaming Lite project is deployed on a Raspberry Pi 2, and this tutorial is part of a larger series dedicated to showing the basic functionalities of Streaming Lite.
Make sure you have completed the following tutorials (in order) before continuing:
- Smart Data Streaming – Freezer Monitoring Tutorial
- Streaming Lite – Freezer Monitoring Lite Tutorial
- Streaming Web Service Configuration and Testing (For SAP HANA Smart Data Streaming)
- Have a SAP HANA SPS10 system with Smart Data Streaming installed to connect to and use
- This tutorial assumes you will be using the HANA SYSTEM user (username/password)
- This tutorial assumes you are familiar with the HANA Studio development environment, PuTTY, and WinSCP
- Have a Raspberry Pi 2 microcontroller board with Streaming Lite installed
- The Raspberry user is “Pi”, and the root directory of the Raspberry Pi is /home/pi
Adding the Output Adapter
Streaming Lite runs a single instance of a streaming project. More specifically, it runs the .ccx file of a compiled Smart Data Streaming project on a remote device. Since we have already created the project “freezer_monitoring_lite”, we will need to edit it, recompile, and redeploy the new .ccx file onto our Raspberry Pi.
1. Open up the project “freezer_monitoring_lite” in HANA Studio.
2. Under “Output Adapters” in the palette, find the “SWS Output” adapter. We will be attaching this adapter to the “FilterEveryFifteenthRow” element.
3. Drag the adapter onto the diagram, and connect it to FilterEveryFifteenthRow
Configuring the Output Adapter
4. Click “Edit Properties”:
5. In the subsequent screen, under the Basic tab, configure the following fields:
a) Protocol: websocket
- Accepted values are “rest” or “websocket”. We will be using websocket since this provides higher throughput for continuous streaming than REST would.
b) Destination Cluster Authentication Data: SYSTEM:<password>
- Replace <password> with the password for the SYSTEM user
- SWS will encode the Authentication Data into base-64 during runtime
c) SWS Server Host: <host>
- Replace <host> with the host name (FQDN) of the machine which the SWS server is running on. This will likely be the same server as your SDS node is running on.
d) SWS Server Port: 9093
- The port number for SWS is defined in the SWS .xml configuration file. The default value is 9093.
e) Destination Workspace Name: default
- We created this streaming project in the default workspace
f) Destination Project Name: freezer_monitoring
- The Smart Data Streaming Project we are writing to
g) Destination Stream Name: MACHINEDATA
- The specific input stream in the freezer_monitoring project we are writing to
6. Go to the advanced tab, and set Use SSL to true. This value must match the value inside the SWS configuration file, which is mentioned in the “Streaming Web Service Configuration and Testing” tutorial. By default, the Streaming Web Service is configured to use SSL. Click ok to exit
Note: It would be good idea to go back into the SWS configuration file and make sure that the value <ssl-enabled> is in fact set to “true”.
Deploying the Streaming Lite Project
7. Compile your project to generate the .ccx file. It will be located in the bin/ directory of your project folder.
8. Connect to your Raspberry with WinSCP, and move this .ccx file into the /home/pi/ directory. If your old project file is still there, overwrite it.
9. Using PuTTY, run the Streaming Lite project with the same command as before:
$HOME/install/bin/streamingproject –ccx $HOME/freezer_monitoring_lite.ccx –command-port 9230
Starting the Streaming Web Service
10. Start the SWS using PuTTY. Connect to the SDS node in your HANA system as the <sid>adm Linux user, and navigate to the $STREAMING_HOME/bin directory. Start the SWS by running:
11. In the SAP HANA Streaming Run-Test perspective in HANA Studio, start the “freezer_monitoring” project and navigate to the stream view for MACHINEDATA. This is where the output from the freezer_monitoring_lite project will appear after being pushed from Streaming Lite to SDS through the SWS Output adapter.
12. PuTTY to your Raspberry Pi, and run this command 15 times. Recall that this is done to simulate 15 rows of temperature values sent into Streaming Lite. After 15 rows, your Streaming Lite project will output one row containing the total temperature average.
echo “isFreezerTemperatureReading,i,RaspberryPi,90,2014-06-03T12:00:00.000,218” | $STREAMING_HOME/bin/streamingconvert -d “,” -p SAPraspberrypi2-B3:9230/freezer_monitoring_lite | $STREAMING_HOME/bin/streamingupload -p SAPraspberrypi2-B3:9230/freezer_monitoring_lite
Alternatively, if you wish to input a large number of rows all at once, you may do so with a .csv file. For example, if we have a .csv file called “data.csv” containing 15 rows, we can input this data into streaming lite by running the following command:
cat data.csv | $STREAMING_HOME/bin/streamingconvert -d “,” -p SAPraspberrypi2-B3:9230/freezer_monitoring_lite | $STREAMING_HOME/bin/streamingupload -p SAPraspberrypi2-B3:9230/freezer_monitoring_lite
13. You should now be able to see that row inside the stream view for MACHINEDATA, back in HANA Studio.
If you do not see the event data arriving in the MACHINEDATA input stream, then refer back to the detailed testing instructions in each of the pre-requisite tutorials for detailed instructions on testing each layer of the system.