distributed reactive programming tools2010

Post on 18-Dec-2014

351 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

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 ScienceVrije Universiteit Brussel

48th International Conference on Objects, Models, Components, Patterns -- TOOLS 2010June 28 - July 2 2010Malàga, Spain

Tuesday 29 June 2010

The mobile ticket trader application

Tuesday 29 June 2010

Pervasive Computing and Mobile Ad Hoc Networks

Tuesday 29 June 2010

Pervasive Computing and Mobile Ad Hoc Networks

Mobile devices

Tuesday 29 June 2010

Pervasive Computing and Mobile Ad Hoc Networks

Mobile devices

Tuesday 29 June 2010

Pervasive Computing and Mobile Ad Hoc Networks

Mobile devices

Intermittent connectivity

Tuesday 29 June 2010

Pervasive Computing and Mobile Ad Hoc Networks

Mobile devices

Intermittent connectivity

Spontaneous interactions

Tuesday 29 June 2010

Pervasive Computing and Mobile Ad Hoc Networks

Mobile devices

Intermittent connectivity

Scarce infrastructure

Spontaneous interactions

Tuesday 29 June 2010

Pervasive Computing and Mobile Ad Hoc Networks

Mobile devices

Intermittent connectivity

Scarce infrastructure

Representation of physical objects

Spontaneous interactions

Tuesday 29 June 2010

Distributed Event-driven Architecture

Pervasive Computing and Mobile Ad Hoc Networks

Scarce infrastructure

Representation of physical objects

Spontaneous interactions

Intermittent connectivity

Mobile devices

Tuesday 29 June 2010

Distributed Event-driven Architecture

Pervasive Computing and Mobile Ad Hoc Networks

Scarce infrastructure

Representation of physical objects

Spontaneous interactions

Intermittent connectivity

Mobile devices

Ad Hoc Discovery

Tuesday 29 June 2010

Distributed Event-driven Architecture

Pervasive Computing and Mobile Ad Hoc Networks

Scarce infrastructure

Representation of physical objects

Spontaneous interactions

Intermittent connectivity

Mobile devices

Decentralized

Ad Hoc Discovery

Tuesday 29 June 2010

Distributed Event-driven Architecture

Pervasive Computing and Mobile Ad Hoc Networks

Scarce infrastructure

Representation of physical objects

Spontaneous interactions

Intermittent connectivity

Mobile devices

Decentralized

Resilient

Ad Hoc Discovery

Tuesday 29 June 2010

Distributed Event-driven Architecture

Pervasive Computing and Mobile Ad Hoc Networks

Scarce infrastructure

Representation of physical objects

Spontaneous interactions

Intermittent connectivity

Mobile devices

Event streams

Decentralized

Resilient

Ad Hoc Discovery

Tuesday 29 June 2010

Distributed Event-driven Architecture

Pervasive Computing and Mobile Ad Hoc Networks

Scarce infrastructure

Representation of physical objects

Spontaneous interactions

Intermittent connectivity

Mobile devices

Event streams

Decentralized

Resilient

Ad Hoc Discovery Broadcasting

Tuesday 29 June 2010

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

Event Loop Concurrency in AmbientTalk

Tuesday 29 June 2010

Event Loop Concurrency in AmbientTalk

“do m immediately”

obj

obj.m()

Tuesday 29 June 2010

Event Loop Concurrency in AmbientTalk

“do m eventually”

obj<-m()

Tuesday 29 June 2010

Event Loop Concurrency in AmbientTalk

“do m eventually”

obj<-m()

Tuesday 29 June 2010

Event Loop Concurrency in AmbientTalk

?

future

Tuesday 29 June 2010

Event Loop Concurrency in AmbientTalk

?

future

when: future becomes: { |value| // process reply}

Tuesday 29 June 2010

Event Loop Concurrency in AmbientTalk

?

future

when: future becomes: { |value| // process reply}

Tuesday 29 June 2010

Publishing & discovering objects by topic

ticketVendor

Tuesday 29 June 2010

Publishing & discovering objects by topic

ticketVendor

deftype TicketVendor deftype TicketVendor

Tuesday 29 June 2010

Publishing & discovering objects by topic

ticketVendor

export: ticketVendor as: TicketVendordeftype TicketVendor deftype TicketVendor

Tuesday 29 June 2010

Publishing & discovering objects by topic

ticketVendor

export: ticketVendor as: TicketVendorwhenever: TicketVendor discovered: { |ticketVendor| // React on ticketVendor appearance when: ticketVendor disconnected: { // React on disappearance } when: ticketVendor reconnected: { // React on reappearance }}

deftype TicketVendor deftype TicketVendor

Tuesday 29 June 2010

Publishing & discovering objects by topic

ticketVendor

export: ticketVendor as: TicketVendorwhenever: TicketVendor discovered: { |ticketVendor| // React on ticketVendor appearance when: ticketVendor disconnected: { // React on disappearance } when: ticketVendor reconnected: { // React on reappearance }}

deftype TicketVendor deftype TicketVendor

Tuesday 29 June 2010

Publishing & discovering objects by topic

ticketVendor

export: ticketVendor as: TicketVendorwhenever: TicketVendor discovered: { |ticketVendor| // React on ticketVendor appearance when: ticketVendor disconnected: { // React on disappearance } when: ticketVendor reconnected: { // React on reappearance }}

deftype TicketVendor deftype TicketVendor

Ad Hoc Discovery

Tuesday 29 June 2010

Publishing & discovering objects by topic

ticketVendor

export: ticketVendor as: TicketVendorwhenever: TicketVendor discovered: { |ticketVendor| // React on ticketVendor appearance when: ticketVendor disconnected: { // React on disappearance } when: ticketVendor reconnected: { // React on reappearance }}

deftype TicketVendor deftype TicketVendor

Ad Hoc Discovery

Decentralized

Tuesday 29 June 2010

Asynchronous communication

ticketVendor

getLocation

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

Asynchronous communication

ticketVendor

getLocation

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

Asynchronous communication

ticketVendor

getLocation

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

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

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

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

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 }}

Resilient

Tuesday 29 June 2010

Ambient References

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 }

werchterVendors

Broadcasting

Tuesday 29 June 2010

Ambient References

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 }

werchterVendors

Broadcasting

Tuesday 29 June 2010

AmbientTalk/R

gui.centerOn(GPS_Location.latitude, GPS_Location.longitude);

GPS_Location

latitude longitude

_.latitude _.longitude

gui.centerOn(_, _)

GPS_Location

Tuesday 29 June 2010

AmbientTalk/R

gui.centerOn(GPS_Location.latitude, GPS_Location.longitude);

GPS_Location

latitude longitude

_.latitude _.longitude

gui.centerOn(_, _)

_.latitude _.longitude

latitude longitude

Tuesday 29 June 2010

AmbientTalk/R

gui.centerOn(GPS_Location.latitude, GPS_Location.longitude);

GPS_Location

latitude longitude

_.latitude _.longitude

gui.centerOn(_, _)gui.centerOn(_, _)

Tuesday 29 June 2010

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.update(lat, lon)};

GPS_Location

Tuesday 29 June 2010

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.update(lat, lon)};

GPS_Location

Event streams

Tuesday 29 June 2010

vendorLocation

vendorLocation

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” };

GUI.showLocationOnM

GPS_Location

_.latitude _.longitude

latitude longitude

gui.centerOn(_, _)

Tuesday 29 June 2010

vendorLocation

vendorLocation

TicketVendorLocation

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” };

GUI.showLocationOnM

GPS_Location

_.latitude _.longitude

latitude longitude

gui.centerOn(_, _)

Tuesday 29 June 2010

vendorLocation

vendorLocation

TicketVendorLocation

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” };

GUI.showLocationOnM

GPS_Location

_.latitude _.longitude

latitude longitude

gui.centerOn(_, _)

Tuesday 29 June 2010

vendorLocation

vendorLocation

TicketVendorLocation

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” };

GUI.showLocationOnM

GPS_Location

_.latitude _.longitude

latitude longitude

gui.centerOn(_, _)

Tuesday 29 June 2010

vendorLocation

vendorLocation

vendorLocation

TicketVendorLocation

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” };

GUI.showLocationOnM

GPS_Location

_.latitude _.longitude

latitude longitude

gui.centerOn(_, _)

Tuesday 29 June 2010

vendorLocation

vendorLocation

vendorLocation

TicketVendorLocation

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @Any vendorLocation := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” };

GUI.showLocationOnM

GPS_Location

_.latitude _.longitude

latitude longitude

gui.centerOn(_, _)

Tuesday 29 June 2010

vendorLocations

vendorLocations

vendorLocations

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @All vendorLocations := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” } timeout: 2000;

GPS_Location

GPS_Location

Tuesday 29 June 2010

vendorLocations

vendorLocations

vendorLocations

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @All vendorLocations := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” } timeout: 2000;

GPS_Location

GPS_Location

GPS_Location

Tuesday 29 June 2010

vendorLocations

vendorLocations

vendorLocations

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @All vendorLocations := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” } timeout: 2000;

GPS_Location

GPS_Location

GPS_Location

Tuesday 29 June 2010

vendorLocations

vendorLocations

vendorLocations

Ambient Behaviors

exportBehavior: GPS_Location as: TicketVendorLocation to: { |buyer| buyer.interestedIn == “Rock Werchter” };

def @All vendorLocations := ambientBehavior: TicketVendorLocation where: { def interestedIn := “Rock Werchter” } timeout: 2000;

GPS_Location

GPS_Location

Tuesday 29 June 2010

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

• Own location changed

• Price of interesting ticket offers changed

def werchterVendors := findOffers(“Rock Werchter”, 120, 500);

gui.updateWithOffers(werchterVendors);

Tuesday 29 June 2010

Reactive Queries

def werchterVendors := ambient: TicketVendor where: { |tv| tv.event == “Rock Werchter”};

def locations := werchterVendors<-getLocation()@Refresh(2.seconds);

locations.each: { |coordinates| GUI.showLocationOnMap(coordinates) };

werchterVendors

Tuesday 29 June 2010

Reactive Queries

def werchterVendors := ambient: TicketVendor where: { |tv| tv.event == “Rock Werchter”};

def locations := werchterVendors<-getLocation()@Refresh(2.seconds);

locations.each: { |coordinates| GUI.showLocationOnMap(coordinates) };

werchterVendors

Tuesday 29 June 2010

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

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/amopcopTuesday 29 June 2010

top related