Home General Staff Contact Partners Alumni Research Areas Projects Papers Books Reports Awards Teaching Lectures Exams B.Theses M.Theses PhD Theses Go Abroad Misc Talks Library Gallery Links Search Webmaster |
Back to index
9 ApplicationsIn this chapter we present two applications of the distributed objects system described in Chapter 7. The first example presented in Section 9.1 extends the Dining Philosophers example from Section 6.2 to the network. It separates the clients (philosophers) from the server (table). The second example shown in Section 9.2 describes the implementation of a distributed file system on top of the distributed objects system.9.1 SynchronisationIn this section we extend the Dining Philosophers example presented in Section 6.2 by separating the clients from the server. The first implementation that relied only on simple semaphores, woiuld have to be rewritten; e.g. a Java application using the wait and notify methods ceases to work as soon as one of the forks is a remote object, as both wait and notify access only the stub object. However, the second implementation that uses locking filters can be adapted without any changes to the logic of the philosophers..Our server represents the table and the synchronisation part of our implementation. The actual activity of the philosophers occurs on the clients, i.e. invocations of Eat by the clients result in a remote method invocation (see Figure 9.1). In order to achieve this we extend the invocations semantics of our non-distributed implementation. The cascade of locking filters builds the server-side semantic. As the client-side semantic we choose DObjects.SyncInvocation. The server defines the desired message semantics and assigns them to the philosophers using DObjects.Export. The implementation is similar to the non-distributed version presented in Section 6.2. MODULE Philosophers;IMPORT Lock, Invocations, DObjects;
TYPE
VAR
PROCEDURE (me: Eater) Think*;
PROCEDURE (me: Eater) Eat*;
PROCEDURE Init*;
si := DObjects.SyncInvocation();
END Philosophers.
The main differences are (bold lines):
The corresponding client is quite simple. It imports the desired philosopher object by calling DObjects.Import. Later invocations will use the assigned semantics. Whenever the method Eat is invoked, the message semantics framework intercepts the invocation and executes the assigned semantic, i.e. it issues a synchronous remote invocation and the server automatically obtains the assigned semaphores before the method is actually executed. The client accesses only one philosopher. We let the user decide which of the 5 philosophers should be impersonated by this client. We chose this approach to emphasise the fact that the 5 philosopers (clients) need not run on the same host, but may also be distributed over the network. MODULE Client;IMPORT Threads, DObjects, Philosophers;
PROCEDURE Start;
PROCEDURE Dinner*;
Threads.Start(p, Start, 10000) END Philosophers. 9.2 Distributed File SystemIn this section we describe a bigger sample application of our distributed objects system. It was developed as a diploma thesis at the Johannes Kepler University. We restrict ourselves to describing the aspects directly related to the distributed objects system and the composable message semantics framework. For a complete overview of the distributed file system see [Lich99].Overview The distributed objects described in this thesis are used as the basis of the implementation of a distributed file system. They enable the programmer to profit from some advantages of object-oriented programming: extensibility, readability and dynamic reconfigurability. We see a file or directory server not as a process but as an object exported by a host. Access to the file server is achieved by using remote method invocations. Therefore, every access to the distributed file system uses the remote access model (except if local decorations are used, e.g. a cache). To enhance performance we offer caching of specific distributed objects (files, directories). Simultaneous access is controlled with the use of locks. Locks and cache are examples for the extensibility of our basic framework. We did not use all semantic degrees of freedom offered by the composable message semantics framework. We used a class-centric view for assigning the invocation semantics to the classes of the distributed file system, i.e. all instances of a given class have the same invocation semantics. Additionally, we did not use all possible semantic options (automatic update, shallow parameters). However, we used the possibility to return shallow copied objects. This feature considerably enhances the implementation of our transparent network access. By using distributed objects we actually prevent almost all distribution aspects from cluttering up the actual file system code. The necessary distribution specific code is almost completely concentrated within the module bodies. We define our semantics and marshallers within them. The code that actually deals with distribution is less than 5% of the complete source code. We implemented two test applications that use the distributed file system: A file dialog and a text editor. They are both based on existing implementations that made use of the local Oberon file system. Their adaptation was mostly straightforward. The main task was the change from the statically bound procedures of the local file system Files, to the dynamically bound methods of DFiles. Examples In this sub-section, we will show some small examples that point out some typical usage patterns of the distributed file system. It demonstrates the view on the file system as seen by an application programmer. A DirServer is the network interface that grants remote hosts access to the local file system. It acts as an intermediate that offers clients access to directories and files. As soon as access has been granted, all communication between the client and the accessed server object is handled directly without involving the directory server. The DirServer exports only directories explicitly configured to be public. DObjects.Export(server, Network.DefaultHost(), serverName, NIL, {}, err);The exported server uses the invocation semantics that were previously defined for all server objects by calling DObjects.SetDefaultClassInfo. The above invocation of DObjects.Export is actually the only explicit export action within the whole distributed file system. All other export actions occur implicitly by returning shallow-copied objects, i.e. the automatic instantiation of the client-side stub objects as return values (anonymous import).Our name space builds on the Localizer concept, which is an extensible mechanism that builds on the URL syntax. A localizer specifies the name of an entity (file or directory), its location and the desired access method. Basically, we use an URL-like syntax to specify file and directory names. URL = "file://" serverName "/" fileNameThis mechanism can be extended by adding additional protocols, e.g. we added the cache protocol in order to add caching to the file returned for the above URL.URL = "cache://file://" serverName "/" fileNameThis mechanism is extensible and one can introduce arbitrary new file access decorators. One could also implement other naming schemes that, e.g. increase location transparency. Our locking and access control mechanisms are implemented using this mechanism.Opening and reading/writing of a remote file are similar to handling a local file. The distribution is completely hidden from the client. VAR |