at:tutorial:distribution
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
at:tutorial:distribution [2007/05/04 09:04] – elisag | at:tutorial:distribution [2007/10/08 13:38] – corrected tvcutsem | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | + | ====== Distributed Programming ====== |
- | This tutorial is under heavy construction! | + | |
- | </ | + | |
- | ====== 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' |
- | 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 |
- | The integration of distribution was one of the main concerns in the design of AmbientTalk | + | |
- | More specifically, as a distributed programming language that adheres | + | Before delving in these topics, we illustrate how to activate |
===== Starting the Network.. ===== | ===== Starting the Network.. ===== | ||
Line 14: | Line 11: | ||
AmbientTalk provides an unique native object, named '' | AmbientTalk provides an unique native object, named '' | ||
- | When the virtual machine goes online, | + | When the virtual machine goes online, the built-in |
+ | |||
+ | Taking a virtual machine | ||
< | < | ||
Line 24: | Line 23: | ||
AmbientTalk provides language support to make some objects available to other objects residing in remote actors by means of the '' | AmbientTalk provides language support to make some objects available to other objects residing in remote actors by means of the '' | ||
< | < | ||
- | defstripe | + | deftype |
def service := object: { | def service := object: { | ||
- | def print(aDoc) { | + | |
- | system.println(" | + | system.println(" |
- | } | + | } |
}; | }; | ||
export: service as: Printer; | export: service as: Printer; | ||
</ | </ | ||
- | When an object its exported by its actor, it becomes discoverable by other actors by means of the service type. Internally, this means that the object is placed in the export table of its actor. As shown in the example, a service type is represented by a [[actors# | + | When an object its exported by its actor, it becomes discoverable by other actors by means of the service type. Internally, this means that the object is placed in the export table of its actor. As shown in the example, a service type is represented by a type tag. This means that services types are not associated with a set of methods, but they denote an abstract publication topic that objects exports. As a type tag, a service type can thus be a subtype of one or more other service types. For example, an object could offer a color printing services by exporting the following |
< | < | ||
- | defstripe | + | deftype |
</ | </ | ||
Line 47: | Line 46: | ||
< | < | ||
when: InstantMessenger discovered: { |messenger| | when: InstantMessenger discovered: { |messenger| | ||
- | when: (messenger< | + | |
- | buddyList.put(name, | + | buddyList.put(name, |
- | system.println(" | + | system.println(" |
- | | + | }; |
}; | }; | ||
</ | </ | ||
Line 57: | Line 56: | ||
< | < | ||
- | We are using a future to get the return value of the '' | + | We are using a future to get the return value of the '' |
</ | </ | ||
Line 63: | Line 62: | ||
As '' | As '' | ||
- | |||
===== Partial Failure Handling ===== | ===== Partial Failure Handling ===== | ||
Line 69: | Line 67: | ||
Let us consider again the example instant messenger application described in previous section to further explain the semantics of AmbientTalk' | Let us consider again the example instant messenger application described in previous section to further explain the semantics of AmbientTalk' | ||
- | When an object discovers a service type, the '' | + | When an object discovers a service type, the '' |
- | - Objects are always passed by far reference, except for isolate objects which are passed by copy. | + | - Objects are always passed |
- Native data types are always passed by copy. | - Native data types are always passed by copy. | ||
- | |||
When a remote far reference receives a messages, it flushes the message to the remote object providing that it is connected. If the remote far reference is disconnected, | When a remote far reference receives a messages, it flushes the message to the remote object providing that it is connected. If the remote far reference is disconnected, | ||
Line 81: | Line 78: | ||
< | < | ||
when: InstantMessenger discovered: { |messenger| | when: InstantMessenger discovered: { |messenger| | ||
- | ... | + | |
- | when: messenger disconnected: | + | when: messenger disconnected: |
- | system.println(" | + | system.println(" |
- | }; | + | }; |
- | when: messenger reconnected: | + | when: messenger reconnected: |
- | system.println(" | + | system.println(" |
- | }; | + | }; |
}; | }; | ||
</ | </ | ||
Line 99: | Line 96: | ||
< | < | ||
when: Service discovered: { | reference | | when: Service discovered: { | reference | | ||
- | | + | |
- | | + | messages := retract: reference; |
- | } | + | } |
} | } | ||
</ | </ | ||
Line 118: | Line 115: | ||
< | < | ||
- | As you may have noticed, the '' | + | As you may have noticed, the '' |
</ | </ | ||
Line 125: | Line 122: | ||
< | < | ||
when: messenger takenOffline: | when: messenger takenOffline: | ||
- | system.println(" | + | |
- | | + | //clean certain resources associated to the buddy |
}; | }; | ||
</ | </ | ||
Line 135: | Line 132: | ||
< | < | ||
- | The complete implementation of the instant messenger application explained along this chapter can be found in the file at/ | + | The complete implementation of the instant messenger application explained along this chapter can be found in the file '' |
</ | </ |
at/tutorial/distribution.txt · Last modified: 2009/01/30 16:13 by tvcutsem