Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Models for Distributed Application

Similar presentations


Presentation on theme: "Programming Models for Distributed Application"— Presentation transcript:

1 Programming Models for Distributed Application
Remote procedure call – client calls the procedures in a server program that is running in a different process Remote method invocation (RMI) – an object in one process can invoke methods of objects in another process Event notification – objects receive notification of events at other objects for which they have registered These mechanism must be location-transparent. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

2 Remote Interface (RMI)
specifies methods of an object available for remote invocation input and output parameters may be objects Remote Method Invocation communication actual arguments marshaled and sent to server server unmarshals packet, performs procedure, and sends marshaled return packet to caller client unmarshals return packet common format definition for how to pass objects (e.g., CORBA IDL or Java RMI) Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

3 1.Design issues for RMI-The Object Model
An object encapsulates data and methods. Objects can be accessed via object references. An interface provides a definition of the signatures of a set of methods(arguments, return values and exceptions) without specifying their implementation Actions are performed by method invocations (object invoks a method in another object.) The state of receiver may be changed. A new object may be instantiated, for example, by using a constructor in Java or C++. Further invocations of methods on other objects may take place.

4 Exceptions may be thrown to caller when an error occurs.
Garbage collection frees the space occupied by objects when they are no longer needed. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

5 The Distributed Objects Model-DOM
Remote method invocation – Method invocations between objects in different processes, whether in the same computer or not. Local method invocation – Method invocations between objects in the same process. Remote object – Objects that can receive remote invocations. Remote and local method invocations are shown in Figure 5.3. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

6 Figure 5.3 invocation remote local A B C D E F each process contains objects, some of which can receive remote invocations, others only local invocations those that can receive remote invocations are called remote objects objects need to know the remote object reference of an object in another process in order to invoke its methods. How do they get it? the remote interface specifies which methods can be invoked remotely Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

7 Two fundamental concepts are the heart of the DOM
Remote object reference Other objects can invoke the methods of a remote object if they have access to its remote object reference. For example, a remote object reference for B in Figure3 must be available to A. Remote interface Every remote object has a remote interface that specifies which of its methods can be invoked remotely. For example, the objects B and F in Figure 5.12 must have remote interfaces. CORBA – uses IDL to specify remote interface JAVA – extends interface by the Remote keyword. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

8 Figure 5.4 A remote object and its remote interface
Data implementation object { of methods Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

9 Actions in a distributed object system
Non-distributed case, an action is initiated by a method invocation, which may result in further invocations on methods in other objects. But in the distributed case, the objects involved in a chain of related invocations may be located in different processes or different computers. When an invocation crosses the boundary of a process or computer, RMI is used, and the remote reference of the object must be available to the invoker Garbage collection in a distributed-object system Exceptions

10 2.Implementation of RMI Figure showed an object A invokes a method in a remote object B. Communication module: Request-Reply Protocol Responsible for providing selected invocation semantics The server selects the dispatcher for the class of the object to be invoked. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

11 The Architecture of Remote Method Invocation
Figure 5.6 object A object B skeleton Request proxy for B Reply Communication Remote Remote reference module reference module for B’s class & dispatcher remote client server Skeleton - implements methods in remote interface. Unmarshals requests and marshals results. Invokes method in remote object. Proxy - makes RMI transparent to client. Class implements remote interface. Marshals requests and unmarshals results. Forwards request. Dispatcher - gets request from communication module and invokes method in skeleton (using methodID in message). carries out Request-reply protocol translates between local and remote object references and creates remote object references. Uses remote object table describe animation - First just shows the figure 5.6 then bring in descriptions of communication and remote reference modules then text on RMI software then proxy, skeleton and dispatcher RMI software - between application level objects and communication and remote reference modules Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

12 Proxy - makes RMI transparent to client
Proxy - makes RMI transparent to client. Class implements remote interface. Marshals requests and unmarshals results. Forwards request. Skeleton - implements methods in remote interface. Unmarshals requests and marshals results. Invokes method in remote object. Dispatcher - gets request from communication module and invokes method in skeleton (using methodID in message). Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

13 Remote Reference Module
Responsibilities translation between local and remote object references remote object table - entry for each remote object held by process - entry for each local proxy arriving remote object reference - creation of remote object references creation of remote object references need to pass a remote object - look up in remote object table (create new remote object reference and add entry if necessary) Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

14 Servants A servant is an instance of a class that provides the body of a remote object. Servants live within a server process. handles the remote requests passed on by the corresponding skeleton. They are created when remote objects are instantiated and remain in use until they are no longer needed, finally being garbage collected or deleted. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

15 RMI Software Proxy - provides remote invocation transparency
marshal arguments, unmarshal results, send and receive messages Dispatcher - handles transfer of requests to correct method receive requests, select correct method, and pass on request message Skeleton - implements methods of remote interface unmarshal arguments from request, invoke the method of the remote object, and marshal the results Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

16 Generation of the classes for proxies, dispatchers and skeletons
The classes for the proxy, dispatcher and skeleton used in RMI are generated automatically by an interface compiler. Dynamic invocation: An alternative to proxies The proxy just described is static, in the sense that its class is generated from an interface definition and then compiled into the client code. Sometimes this is not practical, though Dynamic invocation gives the client access to a generic representation of a remote invocation like the doOperation method The client will supply the remote object reference, the name of the method and the arguments to doOperation and then wait to receive the results. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

17 RMI Server and Client Programs
classes for dispatchers, skeletons and remote objects registration of remote objects with the binder Client classes for proxies of all remote objects binder to look up remote object references cannot create remote objects by directly calling constructors – instead provide factory methods factory method is sometimes used to refer to a method that creates servants, and a factory object is an object with factory methods. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

18 RMI Binder and Server Threads
A binder in a distributed system is a separate service that maintains a table containing mappings from textual names to remote object references. Server threads sometimes implemented so that remote invocation causes a new thread to be created to handle the call server with several remote objects might also allocate separate threads to handle each object What are the advantages/disadvantages of each approach? What other threading organizations could be used? Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

19 RMI Binder and Server Threads
Activation of remote objects A remote object is described as active when it is a running process. A remote object is described as passive when it can be made active if requested. An object that can live between activations of processes is called a persistent object. A location service helps clients to locate remote objects from their remote references. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

20 RMI Distributed Garbage Collection
Aim - recover memory if no reference to an object exist. If there is a reference object should still exists. Java distributed algorithm - based on reference counting The distributed garbage collector works in cooperation with the local garbage collector. . Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000

21 RMI Distributed Garbage Collection
The distributed garbage collection (continued): When remote object B is no longer reachable, it deletes the proxy and invokes removeRef(B). When B.holders is empty, the server reclaim the space occupied by B. Leases in Jini To avoid complicated protocols to discover whether a resource are still used, the resource is leased for use for a period of time. An object representing a lease implements the Lease interface. Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn © Addison-Wesley Publishers 2000


Download ppt "Programming Models for Distributed Application"

Similar presentations


Ads by Google