Your SlideShare is downloading. ×
Distributed Reactive Programming Tools2010
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Distributed Reactive Programming Tools2010

322

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
322
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Loosely-coupled Distributed Reactive Programming in Mobile Ad Hoc Networks Andoni Lombide Carreton, Stijn Mostinckx, Tom Van Cutsem and Wolfgang De Meuter Department of Computer Science Vrije Universiteit Brussel 48th International Conference on Objects, Models, Components, Patterns -- TOOLS 2010 June 28 - July 2 2010 Malàga, Spain Tuesday 29 June 2010
  • 2. The mobile ticket trader application Tuesday 29 June 2010
  • 3. Pervasive Computing and Mobile Ad Hoc Networks Tuesday 29 June 2010
  • 4. Pervasive Computing and Mobile Ad Hoc Networks Mobile devices Tuesday 29 June 2010
  • 5. Pervasive Computing and Mobile Ad Hoc Networks Mobile devices Tuesday 29 June 2010
  • 6. Pervasive Computing and Mobile Ad Hoc Networks Mobile devices Intermittent connectivity Tuesday 29 June 2010
  • 7. Pervasive Computing and Mobile Ad Hoc Networks Mobile devices Spontaneous interactions Intermittent connectivity Tuesday 29 June 2010
  • 8. Pervasive Computing and Mobile Ad Hoc Networks Scarce infrastructure Mobile devices Spontaneous interactions Intermittent connectivity Tuesday 29 June 2010
  • 9. Pervasive Computing and Mobile Ad Hoc Networks Scarce infrastructure Mobile devices Representation of physical objects Spontaneous interactions Intermittent connectivity Tuesday 29 June 2010
  • 10. Pervasive Computing and Mobile Ad Hoc Networks Representation of physical objects Mobile devices Spontaneous interactions Distributed Event-driven Architecture Scarce infrastructure Intermittent connectivity Tuesday 29 June 2010
  • 11. Pervasive Computing and Mobile Ad Hoc Networks Representation of physical objects Mobile devices Spontaneous interactions overy o c Disc Ad H Distributed Event-driven Architecture Scarce infrastructure Intermittent connectivity Tuesday 29 June 2010
  • 12. Pervasive Computing and Mobile Ad Hoc Networks Representation of physical objects Mobile devices Spontaneous interactions overy o c Disc Ad H Distributed Event-driven Architecture Scarce infrastructure ecent ralized D Intermittent connectivity Tuesday 29 June 2010
  • 13. Pervasive Computing and Mobile Ad Hoc Networks Representation of physical objects Mobile devices Spontaneous interactions overy o c Disc Ad H Distributed Event-driven Architecture Res ilien Scarce infrastructure t ecent ralized D Intermittent connectivity Tuesday 29 June 2010
  • 14. Pervasive Computing and Mobile Ad Hoc Networks Representation of physical objects Mobile devices Spontaneous interactions Event streams overy o c Disc Ad H Distributed Event-driven Architecture Res ilien Scarce infrastructure t ecent ralized D Intermittent connectivity Tuesday 29 June 2010
  • 15. Pervasive Computing and Mobile Ad Hoc Networks Representation of physical objects Mobile devices Event streams Spontaneous interactions as ting ro adc overy B o c Disc Ad H Distributed Event-driven Architecture Res ilien Scarce infrastructure t ecent ralized D Intermittent connectivity Tuesday 29 June 2010
  • 16. Distributed Event-driven Architecture • Spontaneous discovery of nearby peers and their ticket offers • Disconnection/reconnection • Location of interesting peers changed • Own location changed • Price of interesting ticket offers changed Tuesday 29 June 2010
  • 17. Event Loop Concurrency in AmbientTalk Tuesday 29 June 2010
  • 18. Event Loop Concurrency in AmbientTalk “do m immediately” obj.m() obj Tuesday 29 June 2010
  • 19. Event Loop Concurrency in AmbientTalk “do m eventually” obj<-m() Tuesday 29 June 2010
  • 20. Event Loop Concurrency in AmbientTalk “do m eventually” obj<-m() Tuesday 29 June 2010
  • 21. Event Loop Concurrency in AmbientTalk ? future Tuesday 29 June 2010
  • 22. Event Loop Concurrency in AmbientTalk ? future when: future becomes: { |value| // process reply } Tuesday 29 June 2010
  • 23. Event Loop Concurrency in AmbientTalk ? future when: future becomes: { |value| // process reply } Tuesday 29 June 2010
  • 24. Publishing & discovering objects by topic ticketVendor Tuesday 29 June 2010
  • 25. Publishing & discovering objects by topic ticketVendor deftype TicketVendor deftype TicketVendor Tuesday 29 June 2010
  • 26. Publishing & discovering objects by topic ticketVendor deftype TicketVendor deftype TicketVendor export: ticketVendor as: TicketVendor Tuesday 29 June 2010
  • 27. Publishing & discovering objects by topic ticketVendor deftype TicketVendor deftype TicketVendor export: ticketVendor as: TicketVendor whenever: TicketVendor discovered: { |ticketVendor| // React on ticketVendor appearance when: ticketVendor disconnected: { // React on disappearance } when: ticketVendor reconnected: { // React on reappearance }} Tuesday 29 June 2010
  • 28. Publishing & discovering objects by topic ticketVendor deftype TicketVendor deftype TicketVendor export: ticketVendor as: TicketVendor whenever: TicketVendor discovered: { |ticketVendor| // React on ticketVendor appearance when: ticketVendor disconnected: { // React on disappearance } when: ticketVendor reconnected: { // React on reappearance }} Tuesday 29 June 2010
  • 29. Publishing & discovering objects by topic ticketVendor deftype TicketVendor deftype TicketVendor export: ticketVendor as: TicketVendor whenever: TicketVendor discovered: { |ticketVendor| // React on ticketVendor appearance covery when: ticketVendor disconnected: { // React on disappearance Ad H oc Dis } when: ticketVendor reconnected: { // React on reappearance }} Tuesday 29 June 2010
  • 30. Publishing & discovering objects by topic ticketVendor deftype TicketVendor deftype TicketVendor export: ticketVendor as: TicketVendor whenever: TicketVendor discovered: { |ticketVendor| // React on ticketVendor appearance covery when: ticketVendor disconnected: { // React on disappearance Ad H oc Dis } when: ticketVendor reconnected: { alized // React on reappearance D ecentr }} Tuesday 29 June 2010
  • 31. Asynchronous communication getLocation ticketVendor when: TicketVendor discovered: { |ticketVendor| when: ticketVendor<-getLocation()@Due(timeout) becomes: { |loc| // Update user interface with the location } catch: TimeoutException using: { |e| // Remove ticket offer from user interface } } Tuesday 29 June 2010
  • 32. Asynchronous communication getLocation ticketVendor when: TicketVendor discovered: { |ticketVendor| when: ticketVendor<-getLocation()@Due(timeout) becomes: { |loc| // Update user interface with the location } catch: TimeoutException using: { |e| // Remove ticket offer from user interface } } Tuesday 29 June 2010
  • 33. Asynchronous communication getLocation ticketVendor when: TicketVendor discovered: { |ticketVendor| when: ticketVendor<-getLocation()@Due(timeout) becomes: { |loc| // Update user interface with the location } catch: TimeoutException using: { |e| // Remove ticket offer from user interface } } Tuesday 29 June 2010
  • 34. Asynchronous communication ticketVendor when: TicketVendor discovered: { |ticketVendor| when: ticketVendor<-getLocation()@Due(timeout) becomes: { |loc| // Update user interface with the location } catch: TimeoutException using: { |e| // Remove ticket offer from user interface } } Tuesday 29 June 2010
  • 35. Asynchronous communication ticketVendor when: TicketVendor discovered: { |ticketVendor| when: ticketVendor<-getLocation()@Due(timeout) becomes: { |loc| // Update user interface with the location } catch: TimeoutException using: { |e| // Remove ticket offer from user interface } } Tuesday 29 June 2010
  • 36. Asynchronous communication ticketVendor when: TicketVendor discovered: { |ticketVendor| when: ticketVendor<-getLocation()@Due(timeout) becomes: { |loc| // Update user interface with the location } catch: TimeoutException using: { |e| // Remove ticket offer from user interface } } Tuesday 29 June 2010
  • 37. Asynchronous communication ticketVendor Res ilien t when: TicketVendor discovered: { |ticketVendor| when: ticketVendor<-getLocation()@Due(timeout) becomes: { |loc| // Update user interface with the location } catch: TimeoutException using: { |e| // Remove ticket offer from user interface } } Tuesday 29 June 2010
  • 38. Ambient References ting werchterVendors as ro adc B def werchterVendors := ambient: TicketVendor where: { |tv| tv.event == “Rock Werchter” }; whenAll: werchterVendors<-getLocation()@Expires(5.seconds) becomes: { |locations| // Update the map GUI with the locations } Tuesday 29 June 2010
  • 39. Ambient References ting werchterVendors as ro adc B def werchterVendors := ambient: TicketVendor where: { |tv| tv.event == “Rock Werchter” }; whenAll: werchterVendors<-getLocation()@Expires(5.seconds) becomes: { |locations| // Update the map GUI with the locations } Tuesday 29 June 2010
  • 40. AmbientTalk/R gui.centerOn(GPS_Location.latitude, GPS_Location.longitude); GPS_Location _.latitude _.longitude latitude longitude gui.centerOn(_, _) Tuesday 29 June 2010
  • 41. AmbientTalk/R gui.centerOn(GPS_Location.latitude, GPS_Location.longitude); GPS_Location _.latitude _.longitude latitude longitude gui.centerOn(_, _) Tuesday 29 June 2010
  • 42. AmbientTalk/R gui.centerOn(GPS_Location.latitude, GPS_Location.longitude); GPS_Location _.latitude _.longitude latitude longitude gui.centerOn(_, _) Tuesday 29 June 2010
  • 43. AmbientTalk/R def Coordinate := isolate: { def latitude := 0; def longitude := 0; def distanceTo(anotherCoordinate) { // Compute via Haversine formula }; def @Mutator update(newLatitude, newLongitude) { latitude := newLatitude; longitude := newLongitude; }; }; def GPS_Location := makeReactive(Coordinate.new()); GPS.addLocationObserver: { |lat, lon| GPS_Location GPS_Location.update(lat, lon) }; Tuesday 29 June 2010
  • 44. AmbientTalk/R def Coordinate := isolate: { def latitude := 0; def longitude := 0; def distanceTo(anotherCoordinate) { // Compute via Haversine formula }; def @Mutator update(newLatitude, newLongitude) { latitude := newLatitude; longitude := newLongitude; }; Event streams }; def GPS_Location := makeReactive(Coordinate.new()); GPS.addLocationObserver: { |lat, lon| GPS_Location GPS_Location.update(lat, lon) }; Tuesday 29 June 2010
  • 45. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; GPS_Location _.latitude _.longitude GUI.showLocationOnM vendorLocation latitude longitude gui.centerOn (_, _) vendorLocation def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” }; Tuesday 29 June 2010
  • 46. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; TicketVendorLocation GPS_Location _.latitude _.longitude GUI.showLocationOnM vendorLocation latitude longitude gui.centerOn (_, _) vendorLocation def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” }; Tuesday 29 June 2010
  • 47. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; TicketVendorLocation GPS_Location _.latitude _.longitude GUI.showLocationOnM vendorLocation latitude longitude gui.centerOn (_, _) vendorLocation def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” }; Tuesday 29 June 2010
  • 48. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; TicketVendorLocation GPS_Location _.latitude _.longitude GUI.showLocationOnM vendorLocation latitude longitude gui.centerOn (_, _) vendorLocation def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” }; Tuesday 29 June 2010
  • 49. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; TicketVendorLocation GPS_Location _.latitude _.longitude GUI.showLocationOnM vendorLocation latitude longitude vendorLocation gui.centerOn (_, _) vendorLocation def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” }; Tuesday 29 June 2010
  • 50. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; TicketVendorLocation GPS_Location _.latitude _.longitude GUI.showLocationOnM vendorLocation latitude longitude vendorLocation gui.centerOn (_, _) vendorLocation def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” }; Tuesday 29 June 2010
  • 51. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; GPS_Location vendorLocations vendorLocations GPS_Location vendorLocations def @All vendorLocations := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” } timeout: 2000; Tuesday 29 June 2010
  • 52. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; GPS_Location vendorLocations GPS_Location vendorLocations GPS_Location vendorLocations def @All vendorLocations := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” } timeout: 2000; Tuesday 29 June 2010
  • 53. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; GPS_Location vendorLocations GPS_Location vendorLocations GPS_Location vendorLocations def @All vendorLocations := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” } timeout: 2000; Tuesday 29 June 2010
  • 54. Ambient Behaviors exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” }; GPS_Location vendorLocations vendorLocations GPS_Location vendorLocations def @All vendorLocations := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” } timeout: 2000; Tuesday 29 June 2010
  • 55. Ambient Behaviors def findOffers(event, maxPrice, maxDistance) { // Subscribe to ticket offers def @All allNearbyOffers := ambientBehavior: TicketOfferT timeout: 2000; // Filter out interesting ticket offers allNearbyOffers.filter: { |offer| (offer.eventName == event).and: { (offer.price <= maxPrice).and: { GPS_Location.distanceTo(offer.location) <= maxDistance }}}; }; • Disconnection/reconnection • Location of interesting peers changed def werchterVendors := findOffers(“Rock Werchter”, 120, 500); • Own location changed gui.updateWithOffers(werchterVendors); • Price of interesting ticket offers changed Tuesday 29 June 2010
  • 56. Reactive Queries werchterVendors def werchterVendors := ambient: TicketVendor where: { |tv| tv.event == “Rock Werchter” }; def locations := werchterVendors<-getLocation()@Refresh(2.seconds); locations.each: { |coordinates| GUI.showLocationOnMap(coordinates) }; Tuesday 29 June 2010
  • 57. Reactive Queries werchterVendors def werchterVendors := ambient: TicketVendor where: { |tv| tv.event == “Rock Werchter” }; def locations := werchterVendors<-getLocation()@Refresh(2.seconds); locations.each: { |coordinates| GUI.showLocationOnMap(coordinates) }; Tuesday 29 June 2010
  • 58. Limitations and Future Work • AmbientTalk/R yields a higher computational overhead than plain AmbientTalk. • Event message order preservation not guaranteed on very fine-grained levels over different communication partners. • No real-time guarantees. • Event consumers can only create and cancel their distributed dependencies: they cannot limit the number of propagated events. Tuesday 29 June 2010
  • 59. Conclusion • Decentralized publish/subscribe architecture based on UDP broadcasting allows spontaneous and loosely-coupled group interactions. • Reactive interpreter allows reacting to and processing of events without relying on “callback-spaghetti”. • Ambient behaviors and reactive queries reconcile both programming styles. • Event propagation happens with asynchronous messages among distributed event loops: no concurrency issues and resilient to intermittent network connectivity. http://soft.vub.ac.be/soft/research/amopcop Tuesday 29 June 2010

×