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:45] – elisag | at:tutorial:distribution [2009/01/28 17:55] – elisag | ||
---|---|---|---|
Line 120: | Line 120: | ||
====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 134: | 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 far reference that remains valid for the indicated time interval (5 minutes in the example). The construct | + | 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 144: | 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 151: | 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 |
} | } | ||
</ | </ |
at/tutorial/distribution.txt · Last modified: 2009/01/30 16:13 by tvcutsem