HSDP Tutorial 1 Prototyping Analytic Solution
HSDP Tutorial 1 Prototyping Analytic Solution
solution
Objectives
The key objective of the lab is to illustrate how to set up a development environment and rapidly
prototype a streaming analysis solution. Using a simple example you will learn how to:
Prerequisite reading
It is highly recommended to review and refer to the workshop document to get a good conceptual
background before starting this tutorial.
Setting up the HSDP working directory: Hitachi Streaming Data Platform, Setup and Configuration
Guide (MK-93HSDP000-04), Chapter 1. Creating working directories
Configuring the analytic query group: Hitachi Streaming Data Platform, Setup and Configuration
Guide (MK-93HSDP000-04), Chapter 2. Developing analysis scenarios using CQL
Example of External Adapter: Hitachi Streaming Data Platform, Setup and Configuration Guide
(MK-93HSDP000-04), Chapter 3. Developing external adapters
Testing analysis scenarios in local mode: Hitachi Streaming Data Platform, Application
Development Guide (MK-93HSDP001-04), Chapter 6. Working with the CQL debugging tool
Command Reference: Hitachi Streaming Data Platform, Setup and Configuration Guide (MK93HSDP000-04), Chapter 5.
CQL Reference: Hitachi Streaming Data Platform, Application Development Guide (MK93HSDP001-04), Chapter 4.
Note: If you are doing the tutorial from the HDS Global Demonstration and Learning Lab (GDLL),
or on the Hitachi Cloud account then you can skip installing HSDP. HSDP is typically installed
under /opt/hitachi/hsdp.
HSDP
Insights
<HSDP-working-directory>/
bin
HSDP tools and commands
conf
Directory for configuration files for query groups.
exadaptor Directory for external adapters
example Directory for sample code
inadaptor Directory for internal adapters
lib
logs
query
spool
trc
Defining a stream that reflects the schema of the input record or tuple
Computing the moving average of energy utilization for every home in a city. In this
example we are computing using a window of 10 minutes and outputting the insights every
10 minutes.
// Define Stream
register stream Smart_meter_stream (
ts timestamp(9), meter_id varchar(4), city_code varchar(2), elec_util
int);
//Compute the moving average
register query Smart_meter_stream_output rstream [10 minute] (
select city_code, avg(elec_util) as elec_util
from Smart_meter_stream [range 10 minute]
group by city_code);
stamp mode set to DataSource this tells the HSDP engine to use the timestamp in the data file
when performing the computations.
# Specify the path to a query definition file that defines a query group.
(Mandatory)
querygroup.cqlFilePath=query/smart_meter_quick_prototype.cql
# Specify timestamp mode. Default is Server mode.
stream.timestampMode=DataSource
# Specify the unit of timestamp adjustment when DataSource timestamp mode is
set.
stream.timestampAccuracy=unuse
# Specify the name of time data column in stream schema. If there is more
than one stream, all of input streams must have this column
stream.timestampPosition=ts
Meter ID
City Code
Energy Utilization
5/30/2016 0:00
5/30/2016 0:00
5/30/2016 0:00
1
2
3
BG
BB
CC
51
51
51
As a convention,
The name of the input file should be the same as the name of stream into which the data is
ingested.
The name of the file should be in uppercase.
The data in the file should be in CSV format that reflects the schema of the stream (each
column should be separated by a comma character ,).
Step 4.3 To test the analysis query, run the following command from the hsdp_rapid_prototype
_tutorial/ directory.
$ ./bin/hsdpcqldebug smart_meter_quick_prototype -i input -o output
Running the command will do the following
Start the HSDP server and execute the query on the incoming data stream.
Read the input file and stream the data into the HSDP server
Step 5 Cleaning up
Step 5.1 Remove the output files and log files by running the following command.
$ rm -rf ./output/* ./logs/* ./trc/*
Step 5.2 Stop the SDP manager by running the following command with root privileges.
$ sudo /opt/hitachi/hsdp/bin/hsdpmanager -stop
Run the lab again with the modifications mentioned earlier and observe the output by running the
following command:
$ ./bin/hsdpcqldebug smart_meter_quick_prototype -i input -o output
Debugging tips
Examine them for debugging any issues when running the labs.
Log file name
Purpose
./log/SDPServerMessage<n>.log
/var/log/hitachi/hsdp/ManagerMessage <n>.log
/var/log/hitachi/hsdp/CoordinatorMessage <n>.log
/var/log/hitachi/hsdp/BrokerMessage<n>.log
End Tutorial.