User Tools

Site Tools


at:tutorial:distribution

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
at:tutorial:distribution [2007/06/19 16:09] tvcutsemat:tutorial:distribution [2007/10/08 13:38] – corrected tvcutsem
Line 1: Line 1:
-<note> +====== Distributed Programming ======
-This tutorial is under heavy construction! +
-</note>+
  
-====== Distributed Programming ======+Building on the actor-based concurrency model explained in the [[actors|previous chapter]], this chapter discusses the distribution provisions of AmbientTalk. For actors to communicate across the boundaries of a single device, actors need to be capable of discovering one another's presence and need to be resilient to intermittent disconnections of their communication partners.
  
-This tutorial chapter discusses how AmbientTalk virtual machines can discover and communicate with each other over the network +These requirements correspond to the cornerstones of the  Ambient-Oriented Programming paradigm. The seamless integration of language support for dealing with partial failures and performing service discovery, hinge on AmbientTalk's concurrency model based on actors and far references. This chapter will explore the discovery mechanisms to create far references which span different devices, and illustrate how such far references are able to deal with intermittent disconnections in mobile ad hoc networks
-The integration of distribution was one of the main concerns in the design of AmbientTalk programming model. +
  
-More specificallyas a distributed programming language that adheres to the Ambient-Oriented Programming paradigm, AmbientTalk incorporates partial failures and discovery lookup facilities at the heart of its distributed programming model. Rather than creating stubs and skeletons to manage remote communications, AmbientTalk integrates them transparently to the developer thanks to its concurrency model based on actors and far references. Far references are in fact a vital feature of the distributed model of AmbientTalk that allows the language to be able to handle the so-called volatile connections featured in mobile ad hoc networks.  This chapter mainly explains the language abstractions to export and discover other remote objects, and handle partial failures. But first, let us start simply by showing how to enable the network functionality.+Before delving in these topicswe illustrate how to activate the network facilities of AmbientTalk in the next section.
  
 ===== Starting the Network.. ===== ===== Starting the Network.. =====
Line 14: Line 11:
 AmbientTalk provides an unique native object, named ''network'',  that responds to two methods that control the network access to an AmbientTalk virtual machine. More specifically, ''network.online()'' and ''network.offline()'' make a virtual machine go online and offline, respectively.  AmbientTalk provides an unique native object, named ''network'',  that responds to two methods that control the network access to an AmbientTalk virtual machine. More specifically, ''network.online()'' and ''network.offline()'' make a virtual machine go online and offline, respectively. 
  
-When the virtual machine goes online, this allows the built-in discovery lookup mechanism to export the local objects and let local objects to find other remote objects. AmbientTalk's discovery support will be further explained in the following section. Taking offline a virtual machine breaks immediately the connections with other virtual machines and thus, all remote reference between them are disconnected. This is a deliberate design choice made to facilitate the simulation of transient disconnections.+When the virtual machine goes online, the built-in service discovery mechanism is able to broadcast the presence of locally discoverable objects to all virtual machines in the environment, as well as acquaint local objects with discoverable objects on other devicesThe precise details of AmbientTalk's discovery support will be further explained in the following section. 
 + 
 +Taking a virtual machine offline on the other hand will immediately sever all connections with other virtual machines and thus, induce a partial failure for all references that transgress the boundaries of a single virtual machine. This is a deliberate design choice made to facilitate the simulation of transient disconnections. Note that such disconnections do not render far references unusable, as we shall explain [[distribution#partial_failure_handling|below]].
    
 <note> <note>
Line 26: Line 25:
 deftype Printer; deftype Printer;
 def service := object: {  def service := object: { 
- def print(aDoc) { +  def print(aDoc) { 
- system.println("printing " +aDoc); +    system.println("printing " +aDoc); 
-    }+  }
 }; };
 export: service as: Printer; export: service as: Printer;
Line 47: Line 46:
 <code> <code>
 when: InstantMessenger discovered: { |messenger| when: InstantMessenger discovered: { |messenger|
-     when: (messenger<-getName()) becomes: { |name| +  when: (messenger<-getName()) becomes: { |name| 
- buddyList.put(name, messenger); +    buddyList.put(name, messenger); 
- system.println("Added buddy: " + name);   +    system.println("Added buddy: " + name); 
-     };+  };
 }; };
 </code> </code>
Line 63: Line 62:
  
 As ''export:as'', both constructs returns a subscription object that responds to a ''cancel'' method that can be used to cancel the subscription so that the block of code is no longer invoked. Note that objects exported by an actor do not trigger the actor's own ''when:discovered:'' nor ''whenever:discovered:'' observers. As ''export:as'', both constructs returns a subscription object that responds to a ''cancel'' method that can be used to cancel the subscription so that the block of code is no longer invoked. Note that objects exported by an actor do not trigger the actor's own ''when:discovered:'' nor ''whenever:discovered:'' observers.
-  
  
 ===== Partial Failure Handling ===== ===== Partial Failure Handling =====
Line 80: Line 78:
 <code> <code>
 when: InstantMessenger discovered: { |messenger| when: InstantMessenger discovered: { |messenger|
- ... +  ... 
- when: messenger disconnected:+  when: messenger disconnected:
-     system.println("Buddy offline: " + name); +    system.println("Buddy offline: " + name); 
- }; +  }; 
- when: messenger reconnected:+  when: messenger reconnected:
-     system.println("Buddy online: " + name); +    system.println("Buddy online: " + name); 
- };+  };
 }; };
 </code> </code>
Line 98: Line 96:
 <code> <code>
 when: Service discovered: { | reference | when: Service discovered: { | reference |
-    when: reference disconnected:+  when: reference disconnected:
-         messages := retract: reference; +    messages := retract: reference; 
-    }+  }
 } }
 </code> </code>
Line 124: Line 122:
 <code> <code>
 when: messenger takenOffline: { when: messenger takenOffline: {
-   system.println("Buddy offline: " + name); +  system.println("Buddy offline: " + name); 
-   //clean certain resources associated to the buddy+  //clean certain resources associated to the buddy
 }; };
 </code> </code>
at/tutorial/distribution.txt · Last modified: 2009/01/30 16:13 by tvcutsem