INF5100 Advanced Database Systems

36 downloads 781 Views 331KB Size Report
The emulator is for testing and making sure things are all right and confirming that the results are correct. □ Each group will receive a couple of time slots where ...
INF5100 Advanced Database Systems

Mandatory Exercise Details & Explanations

Meta Information 





You have 8 weeks to complete the exercise The exercise consists of three parts, and all parts must be answered Discuss and show the queries of the results for task 1–3



Discuss task 4 – 6 with 0.5 to 1 page per question



You may write in English or Norwegian



Please deliver a nicely formatted PDF to [email protected] with queries, text and results

Teams 

2 or 3 students in each group 



 

Exceptions can be made for 1 student groups with extremely good reasons No groups with 4 students

Send wishes to [email protected] Students without groups will be paired randomly

Lab Setup 

You get an account (INF5100-XX) on dmmslab107.ifi.uio.no where XX is your group number 





ssh -Y [email protected]

The password is initially the same as username, but please change it to something else! Each account has one installed instance of 

TinyOS



TinyDB



PostgreSQL



Avrora WSN emulator



Esper

Part I: TinyDB Motivation 







Get practical experience with TinyDB using real motes and an emulator Understand declarative languages for querying sensor networks Use an ordinary DBMS to extract even more information Spot and discuss possible optimizations

Part I: TinyDB 

TinyDB is a small DSMS written for WSNs



We use both an emulator and real sensors









The emulator is for testing and making sure things are all right and confirming that the results are correct Each group will receive a couple of time slots where the experiments on the real sensors can be made The sensors are organized in a three hierarchy and node 0 distributes queries TinyDB is operated through a GUI and can log results to the PostgeSQL DBMS

Part I: TinyDB  

TinyOS and TinyDB are research projects Feel free to look at the TinyOS source code and try the different buttons in the TinyDB GUI, but be aware that not everything works. When compiling TinyOS one has to choose only a few functions in order for it to be small enough to fit on the motes. E.g. windowing is not supported

Part I: TinyDB Starting TinyDB with Emulator 

1) Set old Java version 









[INF5100-XX@dmms-lab107 ~]$ ojava [enter]

2) Start the Avrora WSN emulator 

[INF5100-XX@dmms-lab107 ~]$ avrora [enter]



Verify that port is 2390 + GROUPNR

3) Start the serial port forwarder (Node 0 is connected to it) 

[INF5100-XX@dmms-lab107 ~]$ sf [enter]



Verify that port is 2390 + GROUPNR



Verify that port is 9001 + GROUPNR

4 ) Edit tinyos-1.x/tools/java/net/tinyos/tinydb/tinydb.conf 

Comment out using %: comm-string:serial@COM1$57600



Un-comment: comm-string:sf@localhost$900N (N depends on the group)

5 ) Start TinyDB 

[INF5100-XX@dmms-lab107 ~]$ tinydb [enter]

Part I: TinyDB Starting TinyDB with Real Sensors 

ONLY POSSIBLE IN YOUR ALLOTED TIME SLOTS!



1) Set old Java version 



2 ) Edit tinyos-1.x/tools/java/net/tinyos/tinydb/tinydb.conf 





[INF5100-XX@dmms-lab107 ~]$ ojava [enter] Comment out using %: comm-string:sf@localhost$900N (N depends on the group) Un-comment: comm-string:serial@COM1$57600

3 ) Start TinyDB 

[INF5100-XX@dmms-lab107 ~]$ tinydb [enter]

Part I: TinyDB

Part I: TinyDB 







The sensors are located in the DMMS lab, but you will only access them remotely Use the emulator when you do not have a time slot for the real sensors, and solve the other parts of the assignment The schedule for accessing to the real sensors will be published on the course web page when ready Try to have queries ready if you feel the schedule is tight

Part I: TinyDB 





By clicking “Log to Database” in the TinyDB GUI, your results will be stored in a persistent DBMS You can fetch it from there using PostgreSQL: 

[INF5100-XX@dmms-lab107 ~]$ mypsql



SELECT * FROM queries;



SELECT * FROM ;



\q

If it does not start: 

[INF5100-XX@dmms-lab107 ~]$ ps ax | grep postmaster



[INF5100-XX@dmms-lab107 ~]$ rm ~/INF5100_db/postmaster.pid



[INF5100-XX@dmms-lab107 ~]$ pg_ctl start -l /tmp/INF5100-XX

Part II: Esper Motivation 



Learn about smart homes and automated home-care 

Elderly want to stay at home instead of hospitals



Sensors are cheaper than humans

Combine sensor readings with ideas from Complex Event Processing (CEP)

Part II: Esper 



Each group's home directory contains a directory, ~/workspace/INF5100SmartHomes When solving Part II, use the newer Java version 

 

[INF5100-XX@dmms-lab107 ~]$ njava

[INF5100-XX@dmms-lab107 ~]$ make [INF5100-XX@dmms-lab107 ~]$ ./INF5100

Part II: Esper 







Write queries and listeners to solve the mandatory assignment We use dynamic class loading for the possible additional listeners and event descriptions Create explicit listeners for each task depending on the output we are interested in Place additional compiled listeners and event descriptions together with the other class files



Automatically compiled when writing make



The queries should be written in a separate file



End the queries with ; and separate the queries with a newline

Part II: Esper 













Trace files from two subjects who have been monitored by various types of sensors in a home The data is real, but the sensors are not perfect: Strange events are recorded! The stream name is SensorEvent Sensors report either ON or OFF (activated or deactivated), and an event is modelled as follows: Refrigerator,74,ON,1053313309093 We have represented this as two separate data tuples, where the ON data tuple has a lower timestamp than the OFF data tuple The trace files contain one data tuple per line

Part II: Esper Code 





 

INF5100.java – Takes 4 arguments. Contains methods for nicer printing of timestamps ListenerLoader.java – Dynamically loads the listeners that are specified in SensorEvent.java – Example of an event file and the event description of the data tuples from the trace files INF5100Listener.java – Abstract class to be extended by the listeners SensorEventListener.java – Example of a listener – Wrong edit of this file causes no output! Use “SELECT AS attribute” clause in queries and be aware of order of event.get(attribute)



Queries.dat – Example of a query



Listeners.dat – Example of usage of the listeners

Part II: Esper  

Run a set of CEP queries against trace files to discover complex events All the tasks should be solved with Esper and the interpretation of each query should be explained thoroughly, since there can be many possible solutions



It can be helpful to check the files with sensor readings



Also show results from both the subjects



For each of the tasks show the query, listener files and results



Discuss and explain your solutions



Tutorials and HOWTOs: http://esper.codehaus.org/

Part III: Discussion 



Give examples of the differences between TinyDB and Esper with respect to querying sensor network data Write 1 to 2 pages

Questions? CONTACT & DELIVERY Hans Vatne Hansen [email protected]