Remote Data Sync service is one of the services available in HANA Cloud Platform which can be used to perform bi-directional synchronization of data between many remote databases at the edge and SAP HANA cloud database at the center.

It is a perfect option when you are looking to create occasionally connected applications which are at the edge. Either it’s not economical to have a permanent connection for these applications or the devices are located in a place where there is a poor network – RDSync is the answer. It can be used in IoT scenarios where there are hundreds of sensors streaming data to local SQL Anywhere or UltraLite DB. You can get a centralized consolidated view of all the remote locations by synchronizing them with a single HANA database on HCP.

In this blog, I am going to demonstrate this using few things:

  •     Sensor Device – TI Sensor Tag which has about 10 low-power sensors.
  •     Raspberry PI – Raspberry PI 3 Model B which comes with an inbuilt Bluetooth. This will have SQL Anywhere DB and the Mobilink Sync client.
  •     HCP RDSync service and HANA DB

Sensor data from TI Sensor tag will be stored in a remote database (SQL Anywhere) which is installed in a Raspberry PI. A synchronization program will be executed manually from within the Raspberry PI to sync the data to a consolidated database available in HANA Cloud Platform.

                          RDSync01.png

I had already established half of the setup in my previous blog Internet of Things made simpler with SAP API Management. I also referred this blog Say Hello World with Remote Data Sync Service on HANA Cloud Platform from Supriya Mayank Umbarkar to get started as it focuses on setting up RDSync based on SQL Anywhere on your laptop. I combined the elements from both these blogs to get the below scenario working.

Prerequisites

  • Productive HANA Cloud Platform Account
  • HANA Instance provisioned to your account
  • Remote Data service needs to be enabled for your account
  • Raspberry PI with a sensor device

Enable Remote Data Sync

Navigate to Services menu in your HCP cockpit to enable the Remote Data Sync Service.

                   

Provisioning a HANA Instance to your account

Ensure that you have a HANA instance provisioned to your account. HANA MDC is currently not supported for this scenario. I have a HANA instance by the name rds01 as shown below.

                   

Click on the HANA Database and create a database user by selecting “Database user” link. Once the database user is created, click on the link “SAP HANA Web Based Development Workbench”.

                   

Click on the Security tile and create a new user called “MOBILINK”. It can be any arbitrary name.

                   

Once the user has been created, save your changes and logoff.

                   

Login as the MOBILINK user and now select the tile “Catalog” as shown below.

                   

Click on the SQL icon and issue the below SQL Statement to create a Sensor table.


CREATE TABLE SENSOR_TABLE (ID BIGINT NOT NULL, TEMP DOUBLE, LIGHT DOUBLE);
COMMIT;


Refresh the table folder under MOBILINK Schema to see that the new table has been created.

                   

With this, most of our tasks have been completed in setting up the consolidated database (HANA DB in HCP).

Deploy the Mobilink Server

You need to have HANA Cloud Platform SDK installed on your system to proceed with these steps. If you do not have them, you can download from SAP Development Tools.

Navigate to the directory where the SDK is extracted and set the variables as below.


set hcpaccount=c59c97a90
set hcpuser=i305544
set dbuser=MOBILINK
set dbpass=<password for my mobilink DB user>
set hcphost=ap1.hana.ondemand.com
set hanainstancename=rds01

Once the above variables are set, execute the below three commands using Neo command.


neo.bat deploy -h %hcphost% -a %hcpaccount% -b mobilinkserver -u %hcpuser% -s EMPTY_SITE --runtime mobilink --ev ML_ARGS="-zf -v" -p %hcppass%

                      

The above command would have deployed a Java application (mobilink server) to the HCP account.,


neo.bat bind-hana-dbms -h %hcphost% -a %hcpaccount% -b mobilinkserver -u %hcpuser% -i %hanainstancename% --db-user %dbuser% --db-password %dbpass%
neo.bat start -h %hcphost% -a %hcpaccount% -b mobilinkserver -u %hcpuser% -p %hcppass%

              

Depending on the type of HANA DB, you might have to use either bind-db or bind-hana-dbms. Since I have a productive HANA DB instance, I am using bind-hana-dbms command.

After about 10-15 minutes, you should be able to see a Java application called “Mobilinkserver” started and running in your HCP account.

              

Click on the application and inspect the bindings. You will notice that it has been mapped to the Mobilink server has been mapped to the rds01 HANA DB.

              

If there are any issues with this, check the logs under the logging menu. Once the server is started, you should be able to see a bunch of ML_ prefixed objects in your MOBILINK schema.

              

Create synchronization scripts in Consolidated DB

This step is to prepare your consolidated database for the Synchronization. The reason for mapping Insert Statement with variables has been explained in one of the above blogs.


call ml_add_table_script('V1','SENSOR_TABLE','upload_insert', 'insert into SENSOR_TABLE (ID, TEMP, LIGHT) values ({ml r.ID}, {ml r.TEMP}, {ml r.LIGHT})'); 
call ml_add_user ('MOBI_USER', '',''); 
commit; 

Similarly, execute these two SQL statements to add another two events for your table.



call ml_add_table_script('V1','SENSOR_TABLE','download_cursor','--{ml_ignore}');
call ml_add_table_script('V1','SENSOR_TABLE','download_delete_cursor','--{ml_ignore}');
commit;

This completes the setup of all activities in the consolidated HANA database in HANA Cloud Platform. The next part focuses on the activities involved in setting up the Raspberry PI.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply