Presentation is loading. Please wait.

Presentation is loading. Please wait.

Remote Procedure Call and Remote Object Invocation TANENBAUM-Chapter 2.

Similar presentations


Presentation on theme: "Remote Procedure Call and Remote Object Invocation TANENBAUM-Chapter 2."— Presentation transcript:

1 Remote Procedure Call and Remote Object Invocation TANENBAUM-Chapter 2

2 Remote Procedure Call RPC

3 Conventional Procedure Call a)Parameter passing in a local procedure call: the stack before the call to read b)The stack while the called procedure is active Read(fd,buf,nbytes)

4 Client and Server Stubs Principle of RPC between a client and server program.

5 Steps of a Remote Procedure Call 1.Client procedure calls client stub in normal way 2.Client stub builds message, calls local OS 3.Client's OS sends message to remote OS 4.Remote OS gives message to server stub 5.Server stub unpacks parameters, calls server 6.Server does work, returns result to the stub 7.Server stub packs it in message, calls local OS 8.Server's OS sends message to client's OS 9.Client's OS gives message to client stub 10.Client Stub unpacks result, returns to client

6 Passing Value Parameters (1) Steps involved in doing remote computation through RPC; a shadow remote procedure call stub is put ın the client’s library to make the remote procedure call transparent. At server site server stub is required. 2-8

7 Passing Value Parameters (2) a)Original message on the Pentium b)The message after receipt on the SPARC c)The message after being inverted. The little numbers in boxes indicate the address of each byte. The integer 5 is marshaled correctly but the string is incorrectly inverted… Marshalling is required between two end machines: e.g. Pentium uses Little Ending, Sun uses Big Ending

8 Parameter Specification and Stub Generation a)A n RPC call with different type parameters b)The corresponding message with special format (IEEE #754).

9 Interface Definition  Interfaces can be defined using an Interface Definition Language (IDL)  The coded interface can then be translated into client stub at the client side and server stub at the server side.  Once the stubs are ready, the transmission with the remote counterpart can be achieved based on the available protocol, eg. TCP/IP

10 Extended RPC models: Doors  Original RPC assume remote communication.  If client and server are on the same machine, then more efficient communication may be used, based on IPC system call library.  So called door is used for co-located client server process communication…  In this case, server is registered with a named door, so that it can be uniquely identified by the operating system when named by the clients  In Solaris, door is associated a file name and treated as such.

11 Extended RPC models: Doors-2 Used when both client and server are in the same address space. Few additional system calls are used to implement this: create, fattach, open, door_call, door_return to register with the door and call the door.

12 Asynchronous RPC (1) a)The interconnection between client and server in a traditional RPC: block client until response is received. b)The interaction using asynchronous RPC: block client until request received response is received. 2-12

13 Asynchronous RPC (2) A client and server interacting through two asynchronous RPC calls: client is interrupted by the server to deliver the response for the previous request… 2-13

14 Example: Distributed Computing Environment(DCE: RPC)  DCE RPC is a middleware system between OS and application, developed by so called Open Group.  Services: Distributed file service Directory service Security service Distributed time service  Goal: to provide transparency in all above services, including binding, communication, data type conversion, and language differences… Client and servers can run on different architecture and implemented using different programming languages…  The DCE RPC includes a number of components including languages, libraries, daemons, and utility programs

15 Writing a Client and a Server(1) The steps in writing a client and a server in DCE RPC. Uuidgen- Unique user interface identifier, never generated again by Uuidgen. Uniqueness is guaranteed by encoding location and the time of the day into 128 bit binary number. Client and server can not share the global variables… 2-14

16 Writing a Client and a Server(2)  UUIDGEN generates a unique user identifier and an IDL file with that identifier  The identifier is 128-bit binary number, so that it can never be reused  Interface Definition Language (IDL) file is than allowed to be updated compiled to produce the stubs and the header file  Server and client codes are then written and compiled with corresponding stub and the header file to be linked with the DCE RPC library, to produce the binaries to be run  DCE daemon maintains a table for server endpoints  A directory server maintains the address of the registered servers with their network addresses.  Client get the network address of the machine running the server from the Directory Service and asks the Daemon for the endpoint of the server to send a request…

17 Binding a Client to a Server Client-to-server binding in DCE. RPC performs operation with “at most once” principle. THIS MEANS RPC CALLS ARE NOT REPEATED BY THE CLIENTS, EVEN IN CASE OF SERVER FAILURES… this is done to avoid multiple requests… A server can be marked as idempotent, i.e. to allow repeated access… 2-15

18 Remote Object-based Systems

19 Remote Object Invocatıon (1)  Expansion of idea of RPC to method invocations on remote objects to enhance distributed transparency  This desire is fueled by the concept of the object, in which its internals can be hidden from the outside world by means of well-defined interfaces: state or data is accessible by the methods that can be accessed through interfaces…

20 Remote Object Invocatıon (2)  Principles of RPC can also be applied to objects  Distribution aspects can be hidden behind the object’ interface CORBA is an industry defined standard for distributed application development DCOM is Microsoft counterpart for CORBA, as middleware for the Windows domain of operating systems  Separation between the interface and the object implementation can be explored for distributed applications, so that interface is in one machine while object is on another.  In object based RPC model, counter parts of client stub in conventional RPC is proxy, that of the server is the skeleton to conduct marshalling and un-marshalling, to each others. Note that the object state may or may not be distributed, but if distributed it can be transparent to the application.

21 Remote Object Invocatıon (3): Distributed Object based organization Common organization of a remote object with client-side proxy, ie. interface on the client machine, server on another…. State is not distributed.. 2-16

22 Remote Object Invocatıon (4): Compile time vs Runtime Objects  The objects implemented using Java and C++ are compile time objects, where the objects are instances of classes.  Compile time objects depend on the particular programming language used. It is easier to built such applications.  Alternatively, the distributed objects can be created during the runtime and made programming language independent, wrapped by a rapper so that the implementation appears as an object.  A common approach is to use Adapters in runtime to allow an interface to be converted to what the clients expect.

23 Remote Object Invocation (5): Persistent and Transient Objects  Persistent object continues to exists even if the server cease to exist.  A persistent object is saved on the secondary storage by a server and retrieved into the scope of the server, whenever needed.  Transient objects cease to exist as soon as the servers cease to exist...

24 ROI: Enterprise Java Beans-EJB  EJB is a Jva object that bis hosted by a special server offereng different ways for remote clients to invoke that object.  EJB are imbedded in a container to provide interfaces to the underlying services such as RMI, database access, and messaging, provided by the application server.  Kinds pof EJBs Stateless session beans: transient like displayed lists… Tasteful session beans: session long, like shopping cart… Entity beans: persistent, like customer data… Message-driven beans: stateless, used to react to received subscribed messages…

25 ROI: Object Servers  Used to support distributed objects  It acts as place where objects live  Each object may be assigned a separate thread or a separate thread per invocation  A server can support different policies for different objects, Transient object Separate security conscious objects, Code shared Different thread policies

26 ROI: Object Adapters  An object that requires a policy for its invocation, has to be activated before being invoked  Object adapter is a mechanism that group objects per policy  Thre could be more than one object adapter per server  Object adapter can extract object reference from an invocation request and dispatch the request to the referenced object  Object adaptor can implement a particular policy at ran- time.

27 Handling Communication in ROI

28 ROI: Object binding  In distributed objects case, a system wide object reference is common.  Object references can even be passed as parameters in method invocations.  A process must first be bound to an object’s reference before invoking any of its methods, perhaps using a proxy.  The binding can be implicit, just like local reference; or it can be explicit in which it needs to find the object before being bind.

29 ROI: Implementation of Object References  Object reference depicts the address of the server object which include the machine it resides, the server identification, and the object identification  The transparency can be improved by using server location servers that keep track of the machine where the servers are and their endpoints on those machines  As a further transparency, an object reference may have additional information, such as the protocols implemented by the object  This may lead to use of an implementation handle, which dynamically loads the object specific proxy to provide binding: So clients need not to worry about the details of the implementation.

30 ROI:Binding a Client to an Object a)An example with implicit binding using only global references b)An example with explicit binding bind using global and local references Distr_object* obj_ref;//Declare a systemwide object reference obj_ref = …;// Initialize the reference to a distributed object obj_ref-> do_something();// Implicitly bind and invoke a method (a) Distr_object obj_ref;//Declare a systemwide object reference Local_object* obj_ptr;//Declare a pointer to local objects obj_ref = …;//Initialize the reference to a distributed object obj_ptr = bind(obj_ref);//Explicitly bind and obtain a pointer to the local proxy obj_ptr -> do_something();//Invoke a method on the local proxy (b)

31 ROI: Static vs Dynamic RMI  Static remote method invocation implies imbedding the object interfaces into the program, thus requires recompilation if the object interface changes.  In dynamic invocation, the method to invoke is selected at run time.  Examples from th book: static rmi, appending an integer to a file object:  fobject.append (int) dynamic rmi, first acquiring an identifier for the method append, before binding the integer int:  invoke(fobject, id(append),int), d) where id(append) returns an identifier for the method append.

32 ROI: Parameter Passing is a problem The situation when passing an object by reference or by value. The distinction in local and global parameters is visible even in object oriented languages. Ref to O1 is by value(L1), reference to O2 is by reference (R1). 2-18

33 Example: The DCE Distributed-Object Model (1)  DCE advocates have to prove that DCE can actually be object based!  DCE objects may be accepted as refinement of RPC, with a shift from procedure call to remote method invocation.  DCE distributed objects are specified in IDL and implemented in C++, created by the server making methods available to the clients  Distributed dynamic objects are created by the server only, on clients request and associated with it  Distributed named object is created and registered with a directory service to be shared by more clients Each remote object invocation is done by an RPC, with all the details required as parameters to the object server which maintains an object table with their identifiers and interface identifiers to dispatch the requested methods….  Binding is done by a handle (in the form of an identifying string), there is no system wide transparent object referencing mechanism. This makes parameter passing in DCE object model harder, as the implementation is some sort of refinement of the RPC parameter passing

34 The DCE Distributed-Object Model (2) a)Distributed dynamic objects in DCE. b)Distributed named objects 2-19

35 Java Distributed Object Model(2)  In Java, distributed objects are imbedded into the language.  Java remote object is a distributed object whose state is kept on one machine, but the interface is made available to remote processes.  Cloning remote and local objects is not the same.  Java allows each object to be constructed as a monitor, by declaring a method as synchronized.  If two clients simultaneously call a synchronized method one has to wait…However synchronization may be implemented on the local stub (proxy) or the server stub  RMI seems to restrict synchronization, ie. blocking, to the client side proxies, rather than server side blocking.  This may not prevent simultaneous access to the remote object, which means explicit distributed locking techniques are required.

36 Java Distributed Object Model(2)  With RMI, any serializable object can be passed as parameter (platform dependent objects such as file or socket descriptors cannot be serializable).  Local objects are passed by value, remote objects are passed by reference, as in case of DCE objects.  Client and server stubs are generated from the interfaces implemented by the respective classes.  Although, the stubs are serializable objects and they can be marshaled and passed over to servers as remote references, RMI implements stub implementation handlers which are smaller in size as they replace the marshaled code….  It is also possible to arrange for servers to pass over (downloaded by the clients) marshaled client side code whenever a client binds to the object, which is not possible in DCE object model.  Dynamic changes to the state of a proxy object needs to refreshed to reflect the changes in the server…  Passing proxies as parameter is possible only because the JVM is the same everywhere.


Download ppt "Remote Procedure Call and Remote Object Invocation TANENBAUM-Chapter 2."

Similar presentations


Ads by Google