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 [2009/01/28 17:34] – elisag | at:tutorial:distribution [2009/01/29 16:26] – * elisag | ||
---|---|---|---|
Line 19: | Line 19: | ||
</ | </ | ||
- | ===== Exporting and discovering objects | + | ===== Exporting and Discovering Objects |
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 '' | ||
Line 114: | Line 114: | ||
====Leased Object References==== | ====Leased Object References==== | ||
- | A leased object reference is a remote far reference that grants access to a remote object for a limited period of time. When the time period has elapsed, the access to the remote object is terminated and the leased reference is said to expire. Similarly to remote far references, a leased reference abstracts client objects from the actual network connection state. Client objects can send a message to the remote object even if a leased references is disconnected at that time. Message are accumulated in order to be transmitted when the reference becomes reconnected. When the leased reference expires it, messages are discarded since an expired leased reference behaves as a permanently disconnected remote far reference. | + | A leased object reference is a remote far reference that grants access to a remote object for a limited period of time. When the time period has elapsed, the access to the remote object is terminated and the leased reference is said to //expire//. Similarly to remote far references, a leased reference abstracts client objects from the actual network connection state. Client objects can send a message to the remote object even if a leased references is disconnected at that time. Message are accumulated in order to be transmitted when the reference becomes reconnected. When the leased reference expires it, messages are discarded since an expired leased reference behaves as a //permanently// disconnected remote far reference. |
+ | |||
+ | {{ : | ||
====Working with leased object references==== | ====Working with leased object references==== | ||
- | The code snippet below illustrates a leased far reference in the context of an online shopping application. In the example, a client object can ask a server to start a shopping session by sending it the openSession message. In response to this message, the server returns a new session object which implements methods that allow a client to place items in its shopping cart or to check out. The returned session gets leased by means of the lease:for: construct. | + | The code snippet below illustrates a leased far reference in the context of an online shopping application. In the example, a client object can ask a server to start a shopping session by sending it the '' |
< | < | ||
Line 132: | Line 134: | ||
</ | </ | ||
- | The lease:for: construct takes as parameters a time interval (in milliseconds) and the remote object to which it grants access, and returns a leased | + | The '' |
+ | |||
+ | < | ||
+ | We assume the use of futures to get the return value of the '' | ||
+ | </ | ||
At client side, a customer can ask a server to open a shopping session as follows: | At client side, a customer can ask a server to open a shopping session as follows: | ||
Line 142: | Line 148: | ||
</ | </ | ||
- | The future attached to the openSession message will be resolved with a leased reference to a session object which remains valid for the next 5 minutes. From that moment on, the client can use the leased reference as if it were the session object itself until it expires. Similar to far references, client objects can only send messages to service | + | The future attached to the '' |
< | < | ||
Line 149: | Line 155: | ||
</ | </ | ||
- | The renew: construct requests a prolongation of the specified leased reference with a new interval of time which can be different than the initial time. The revoke: construct cancels the given leased reference. Cancelling a lease is in a sense analogous to a natural expiration of the lease, but it requires communication between the client and server side of the leased reference. | + | The '' |
- | When no renewal is performed due to a network partition outlasting the lease time period or in absence of utilization, | + | When no renewal is performed due to a network partition outlasting the lease time period or in absence of utilization, |
< | < | ||
when: mySession expired: { | when: mySession expired: { | ||
- | ... // free up resources used by this session | + | ... // free up resources used by this session |
} | } | ||
</ | </ | ||
Line 162: | Line 168: | ||
====Leasing patterns==== | ====Leasing patterns==== | ||
- | |||
As is the case in other leasing mechanisms, determining the proper lease renewal period is not straightforward and may even depend on system parameters such as the number of clients. In AmbientTalk, | As is the case in other leasing mechanisms, determining the proper lease renewal period is not straightforward and may even depend on system parameters such as the number of clients. In AmbientTalk, | ||
- | The first variant is a renew-on-call leased reference which automatically prolongs the lease upon each method call received | + | The first variant is a //renew-on-call// leased reference which automatically prolongs the lease upon each method call received |
- | by the remote object. In other words, as long as the client uses the remote object, the leased reference is transparently renewed by the interpreter. | + | by the remote object. In other words, as long as the client uses the remote object, the leased reference is transparently renewed by the interpreter. |
< | < | ||
Line 180: | Line 185: | ||
</ | </ | ||
- | Similar to lease:for: , this construct takes as parameters a time interval (in milliseconds) and the remote object to which it grants access, and returns a leased | + | Similar to '' |
- | The second variant is a single-call leased reference which automatically revokes the lease upon performing a successful method call on the remote object. | + | The second variant is a //single-call// leased reference which automatically revokes the lease upon performing a successful method call on the remote object. |
< | < | ||
Line 191: | Line 196: | ||
</ | </ | ||
- | Similar to its other two counterparts | + | Similar to the other two constructs, '' |
- | expires after the remote object receives a single message. However, if no message has been received within the specified time interval, the leased reference also expires. | + | |
====Integrating leasing with future-type message passing==== | ====Integrating leasing with future-type message passing==== | ||
Line 198: | Line 202: | ||
Single-call leases are useful for objects adhering to a single call pattern, such as callback objects. Callback objects are often used in asynchronous message passing schemes in order for remote object to be able to return values. These callback objects are typically remotely accessed only once by remote objects with the computed return value. In AmbientTalk, | Single-call leases are useful for objects adhering to a single call pattern, such as callback objects. Callback objects are often used in asynchronous message passing schemes in order for remote object to be able to return values. These callback objects are typically remotely accessed only once by remote objects with the computed return value. In AmbientTalk, | ||
- | We have integrated leasing into futures by parameter-passing a future attached to an asynchronous message via a singe-call lease which either expires due to a timeout or upon the reception of the computed return value. The timeout for the implicit single-call lease on a future can be set by annotating the asynchronous message with a @Due annotation as follows: | + | We have integrated leasing into futures by parameter-passing a future attached to an asynchronous message via a singe-call lease which either expires due to a timeout or upon the reception of the computed return value. The timeout for the implicit single-call lease on a future can be set by annotating the asynchronous message with a '' |
< | < | ||
Line 209: | Line 213: | ||
</ | </ | ||
- | If the future is resolved, the session variable stores a leased object reference to the remote session object. | + | If the future is resolved, the session variable stores a leased object reference to the remote session object. |
< | < | ||
- | Note that specifying a catch: block for the TimeoutException is equivalent to installing a when: | + | Note that specifying a '' |
</ | </ | ||
====Importing leased object references==== | ====Importing leased object references==== | ||
- | Similar to futures, leased object references have been built reflectively on top of AmbientTalk. | + | Similar to futures, leased object references have been built reflectively on top of AmbientTalk. |
To use the language constructs for leased references, you should import the leasedref module as follows: | To use the language constructs for leased references, you should import the leasedref module as follows: | ||
- | import /.at.lang.leasedref; | + | < |
- | + | import /.at.lang.leasedrefs; | |
- | < | + | </ |
- | leasedref | + | < |
+ | leasedrefs | ||
</ | </ | ||
- | More information pertaining to the API of the leased references language module can be found in the appendix. | + | More information pertaining to the API of the leased references language module can be found in the [[appendix|appendix]]. |
- | ===== Garbage collecting remote references | + | ===== Taking Offline Remote Objects |
- | < | + | AmbientTalk distributed memory management scheme has been based on [[http:// |
- | Under Construction: | + | |
- | Update this section | + | |
- | </note> | + | |
- | As explained in the previous section, AmbientTalk' | + | As previously |
< | < | ||
Line 241: | Line 243: | ||
</ | </ | ||
- | The construct removes | + | The primitive takes as parameter an object which is removed |
- | + | ||
- | < | + | < |
- | As you may have noticed, | + | [[distribution# |
</ | </ | ||
- | On the client side, taking offline an object results in a permanent disconnection of the remote references pointing to it. In other words, despite having network connection, unexporting an object renders remote far references permanently disconnected. This implies that client have to deal explicitly with unexported objects. | + | ====Working with objects taken offline==== |
+ | |||
+ | On the client side, taking offline an object results in a permanent disconnection of the remote | ||
+ | |||
+ | Clients can get notified when an object is taken offline by means of '' | ||
+ | |||
+ | Additionally, | ||
< | < | ||
Line 256: | Line 264: | ||
</ | </ | ||
- | Be aware that unexporting a object will not only trigger | + | The construct takes as parameter a far reference and a block of code that is executed when the taken offline event is notified |
- | + | ||
- | Note that disconnection, | + | |
< | < | ||
- | The complete implementation of the instant messenger application explained along this chapter | + | Disconnection, |
</ | </ | ||
+ | |||
+ | ====Distributed unit testing and takeOffline==== | ||
+ | |||
+ | As previously mentioned, the '' | ||
+ | |||
+ | These semantics is useful for unit test purposes. The [[appendix# | ||
+ | |||
+ | By means of the '' |
at/tutorial/distribution.txt · Last modified: 2009/01/30 16:13 by tvcutsem