On Meta-Management of Spatio-Temporal Data Goce Trajcevski DbSN Lab Dept. of EECS Northwestern University goce@eecs.northwestern.edu Joint work with: Zachary Bischof, Oliviu Ghica, Nikoly Valtchanov, Peter Scheuermann IGERT-UIC-Sep09 Pre-Motivation Context: Any information pertaining to a given situation that can be used to characterize the entities of interest – e.g., GUIDE project Personal (location, interests, preferred meals) Environmental (time of day, locations of Situation? attractions time predictable attributes IGERT-UIC-Sep09 place Unpredictable (instantaneous) attributes with continuous impact Pre-Motivation –Combined Situational Awareness Nurse on duty in Assisted Living Residence Resident experiences high temperature and manifests food poisoning Physician is the nearest hospital is aware and monitors The symptoms worsen Physician decides to send ambulance The number of residents with similar symptoms dramatically increases in a short time Not enough nurses Not enough physician on staff in the nearest ER Not enough many ambulances IGERT-UIC-Sep09 Pre-Intro: Context-Awareness in Distributed Dynamic Settings “If an object has been continuously moving towards RI for more than 5min., begin tracking it with at least 2 cameras when it gets closer than 100 yards. Subsequently, if that object is identified as human carrying a bag, maximize the focus of the closest camera, and transmit its stream to the monitor in the closest patrol vehicle”. Outline Background Active Databases and ECA (++) Mobility and Evolving Reactive Behavior (ECA)2 and Meta-Triggers Experimental Observations Concluding Remarks IGERT-UIC-Sep09 Background: Active Databases Evolution = insert; delete; update (…) Integrity Constraints (IC): -Violation? Fix it ECA = Basic Paradigm of the Reactive Behavior: Triggers (AKA Active Rules) ON EVENT IF CONDITION THEN ACTION IGERT-UIC-Sep09 seemingly straightforward, but incorporates an interplay of many semantic dimensions Background: Active Databases IMPORTANT: occurrence of an “entity of interest” detection Event = primitive internal Condition = Action = IGERT-UIC-Sep09 composite external Event Algebras: • E1 E2 (conjunction) • E1; E2 (sequence) • … typically, a query (SQL expression) (sequence of) SQL, mostly DML, statements Background – Active Databases Why ECA? Why not all: Event Action? After all: -Composite Events -Formalisms (AKA Algebras) -Detection “tools” (e.g., Petri Nets) -Interval vs. Instantaneous -ENS have been around… COST: interrupt context-switch Why not all: Condition Action? After all: -OPS-like ; -Formalisms (Temporal Logic) -Expert Systems, Deductive Databases have been around… COST: polling potential_waste… DBMS collaborates closely with, but is NOT the OS events are “seen” only through the “lens” of transactions… (e.g., insert, delete) conditions are SQL queries (optimized) IGERT-UIC-Sep09 Background – Triggers in Mobile Networks (TRG) Base station handover: 2G/3G mobile phones opt for 3G connectivity Traffic load TRG identifies Producers and Consumer Similar to “publishers “ and “subscribers” in ENS Serves as a “point of reference Ensuring a consistent enforcements of rules/policies NOTE: Same entities can be both consimers (of triggers) and producers (of events) IGERT-UIC-Sep09 Background – TRG Mobility aspects: Routing groups formation/maintenance (e.g., cluster-head selection) Roadside base station Inter-vehicle communications Vehicle-to-roadside communications VSN-enabled vehicle Sensors Video IGERT-UIC-Sep09 Chem. Systems Storage Proc. Background – TinyDB and Triggers SQL: SELECT AVG(volume) FROM sensors WHERE floor = 6 GROUP BY room HAVING AVG(volume) > threshold SAMPLE PERIOD 30S ECA-triggers? (so called, actuation queries) SELECT nodeid, temp FROM sensors WHERE temp > threshold OUTPUT ACTION power-on(nodeid) SAMPLE PERIOD 10s Event-Based: ON EVENT bird-detect(loc) SELECT avg(LIGHT), AVG(temp), event.loc FROM sensors AS s WHERE dist(s.loc, event.loc) < 10m SAMPLE PERIOD 2s FOR 30s IGERT-UIC-Sep09 (ECA)2 – Evolving and Context-Aware Event-Condition-Action Active Databases Expert Systems (OPS5) Events Management Triggering Engine IGERT-UIC-Sep09 Events Notification Systems Continuous Queries Processing Triggers and Mobile Nodes TinyDB Why/What else? Postulate: In many dynamic settings, the need for detecting a particular event(s) and/or monitoring particular conditions arises only after: 1. certain events have been detected 2. certain continuous conditions (do not) hold The perception of “event” and “condition” can vary (especially in distributed settings) Meta-Management – Definition Data tuples; objects; etc. Meta-Data Data “about the data” Types, Schemas, etc. Data Management Storage/retrieval Efficient query processing Meta-Management Which queries to be processed when; How to steer the data generation/gathering And do it efficiently, with some QoD guarantees… IGERT-UIC-Sep09 Evolving Reactive Behavior WHEN an object is continuously_moving_towards the region R for more than 5 min., IF there are less then 10 jets in the base B1, then send alert_b to the armored unit A1. Air-Base B1 R Also send alert_a to the infantry regiment I1, WHEN *that* object is closer than 3 miles to R, IF all the marine units are further than 5 miles from R. To send, or not to send… A little “algorithmic-flavor”: continuously_moving_towards R for 6 min. 1. Generate the Voronoi diagram 2. “Shoot-a-ray take-a-walk” 3. Update the time_accumulator accordingly!!! IGERT-UIC-Sep09 A F E B C D Triggers for that Evolving Reactive Behavior Trigger: ON E_Moving_Towards(O,’R’,5,T) IF Jets_Count(‘B1’,X,T) and X<10 AND T1>=T AND within_event(E_Moving_Towards(O,’R’,5,T1)) THEN Alert(‘b’,’A1’) (also): Span Consumed-by-Parent = no, Consume-Parent = no ON E_Distance(O,’R’,3,T2) IF Distance(‘Marines’,’R’,Y,T2) AND T2>T AND Y>=5 THEN Alert(‘a’,’I1’) No longer Moving-Towards Event Moving-Towards Detected IGERT-UIC-Sep09 Distance Event Detected = CHILD OF THE ORIGINAL TRIGGER (ECA)2 – Evolving and Context-Aware Event-Condition-Action When the body network of a resident signals readings which have been continuously approaching a threshold value for longer then 3 min. If the number of on-site physicians < number of endangered residents Notify the nearest k hospitals, requesting emergency vehicles with/without physicians Subsequently, When some of the k ambulances en-route experiences heavy traffic congestion, If the delay in the expected arrival time is > 50% (with respect to the original arrival time) Notify another hospital, requesting emergency vehicle… IGERT-UIC-Sep09 (ECA)2 – Evolving and Context-Aware Event-Condition-Action ON E_Increase(Signal,3, patient_i, T) IF Physician_Count(T,m) AND Endangered_Patients(T,n) AND m < n AND within_validity(Signal,patient_i) THEN Alert_Nearest_Hospitals(Ha,k) Fork: Consumed-by-Parent = yes, Consume-parent = no ON Traffic_Abnormality(T1,V1) IF Expected_Arrival(V1,T2,T1) AND Expected Arrival(V1,T3,T) AND T2 – T > 1.5(T3 – T1) THEN Alert_Nearest_Hospital(Hb,1) Event “E_Increase” detected Event “E_Traffic_Abnormality” IGERT-UIC-Sep09 (ECA)2 – Syntax ON Ep(VEp) <priority> validity(Tpv /Epv(VEpv)) IF Cp1(VCp1) within_time(Tc1)/within_event(Ec1(VEc1)) THEN Ap1(VAp1) ELSE-IF Cp2(VCp2) within_time(Tc2)/within_event(Ec2(VEc2)) THEN Ap2(VAp2) ..... Span (child’) Consumed-by-Parent=<yes/no>, Consume-Parent=<yes/no> ON Ec1(VEc1) <priority> validity(Tc1v/Ec1v(VEc1v)) IF Cc11(VCc11) within_time(Tc11)/within_event(Ec11(VEc11)) THEN Ac11(VAc11) ELSE-IF ... Further nesting of children Subsequently (child’’) Consume-Parent=<yes/no> ON Es1(VEs1) <priority> validity(Ts1v/Es1v(VEs1v)) IF Cs11(VCs11) within_time(Ts11)/within_event(Es11(VEs11)) THEN As11(VAs11) ELSE-IF… Further nesting of children IGERT-UIC-Sep09 (ECA)2 and the Meta-Triggers OBSERVE: ON E_Moving_Towards(O,’R’,5,T) IF Jets_Count(‘B1,X,T) and X<10 AND T1>=T AND within_event(E_Moving_Towards(O,’R’,5,T1)) THEN Alert(‘b’,’A1’) It is very likely that Jets_Count(‘B1’,X,T) will be maintained by a remote server, for Whom a remote-request is nothing but an instantaneous query But, then the “local site” (monitoring “moving_towards”) will have to “ship” such queries upon every new detection… PLUS, it may miss some important changes at the airport in-between updates (pull-mode) REMEDY: 1. Tell the remote site to make the query continuous; 2. Tell the remote site to setup a trigger for certain values of that continuous query 3. “Remember” locally that now instead of asking the query for the condition, you are actually expecting an arrival of an event from the airport database (push mode!!!) IGERT-UIC-Sep09 (ECA)2 and the Meta-Triggers In general, initially we have a local TR1: ON E1 IF CRemote AND CLocal THEN A1 Meta-Trigger (input) (output) TR1’: ON E1; (E-requested-remote; E-notification-from-remote) AND CLocal THEN A1 IGERT-UIC-Sep09 ??? TR1-Remote: ON E-requested-remote IF CContinuous THEN A(E-notification-to-remote) (ECA)2 and the Meta-Triggers: HOW…??? WSN Programming Languages: “borrow” the semantics from existing paradigms Event-driven; SQL-based; Functional/dynamically typed Node-Level: NesC; TinyScript;… Target individual sensors and, generally, same code running on individual nodes; Mostly imperative; executable code (Flash); flow control based on events/communication Network-Level: TinySQL – query optimization; TinyScript – “more accessible” programming (dynamically typed imperative language) SDlog – declarative networking; Datalog based (“@”; “#”) Most likely, interpreted languages (Mate’; Trickle) IGERT-UIC-Sep09 Hypothetical Reasoning High-Level Specification (Domain-Description) Language Based on Action Theories (well-defined semantics) Enables hypothetical reasoning for queries Domain Description = effects of executing actions: A causes F1 if Fi, Fj, …, Ek, Em,… A induces E1 when Fl, Ft, …, Er, Es, … F = facts (i.e., tuples) E = valid events Plus, the expressions which define the ramifications F1, F2, …, E1, E2, … suffice_for F/E Action_Read_Radar induces Event_Location_Determined (NOTE: No Condition) Event_Location_Determined, Time_Towards_Accumulator > 5 suffice_for E_Continuously_Moving _Towards AUGMENTED WITH (ECA)2 TRIGGERS IGERT-UIC-Sep09 Hypothetical Reasoning Basic “vehicles” are queries of the form: L after [A1,A2,…,An] at F1, F2, … E1, E2… Will the Fact/Event L hold in a state which is generated after the sequence of actions [A1, A2, …, An] is executed, starting in a state at which F1, F2, …, E1, E2, … hold? Design: experts from different domains involved Deployment: status of the system and/or impact of modifications. IGERT-UIC-Sep09 Hypothetical Reasoning Example: Will I have sufficient defense resources if 20 objects are continuously moving towards R for more than 5 minutes within half an hour, approaching from North-West, and three of them are within 3 miles. Sufficient defense resources = More than 5 F15s in the air-base B1 and more than 17 Type A1 Marksman in the infantry unit A1 Formally: (Count(Airplanes(F15,B1)) > 5 AND (Count(Infantry(A1,Marksman)) > 17) after [ Moving_towards(X1,'R','NW',5,T1) AND Moving_towards(X2,'R','NW',5,T2) AND … Moving_towards(X20,'R','NW',5,T20) ] AND (T1<T2 … < T20)AND (T20 - T1 < 30) AND [ (Distance(Xi,'R') < 3) AND (Distance(Xj,'R') < 3) AND (Distance(Xk,'R') < 3) ] IGERT-UIC-Sep09 TelosB – Proof of Concept… IGERT-UIC-Sep09 SID-net = Tool for hypothetical reasoning 150000x150000 ft2 (500 Mica2 Motes) IGERT-UIC-Sep09 Simulation Observations IGERT-UIC-Sep09 Pre-Conclusion: The “say-so” of The Network… IGERT-UIC-Sep09 Concluding Remarks Meta-Management of Spatio-Temporal Data Contexts; Evolution and Reactive Behavior with Pro-Active Consequences Meta-Triggers; Fabric vs. Thread… Ongoing Work: Translation to NDlog Possible “type-extensions” Fusion with TinyDB Event-Base Other popular spatio-temporal queries Uncertainty Distributed (meta) indexing IGERT-UIC-Sep09 Thank You! IGERT-UIC-Sep09 (ECA)2 Additional Example When a patient has been continuously moving towards the lake OR the perimeter fence for more then 5 min. If there is no nurse within 50 ft. from him Notify the security personnel Subsequently, When that person has been continuously moving along the lake for more than 1 min. If there is no nurse or security within 100 ft. from the lake Notify the nurses IGERT-UIC-Sep09 (ECA)2 – Additional Example ON E_Moving_Towards(5, Patient, T, lake) OR E_Moving_Towards(5, Patient, T, fence) IF Distance(Nurse, Patient, T) > 50 THEN Alert(Security, T) Fork: Consumed-by-Parent = no, Consume-parent = no ON E_Moving_Along(1,Patient,T1, lake) IF Distance(Nurse,Patient,T1) > 100 AND Distance(Security,Patient,T1) > 10 THEN Alert(Nurse, T1) Event “E_Moving Towards” Event “E_Moving_Along” IGERT-UIC-Sep09