Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.

Similar presentations


Presentation on theme: "Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan."— Presentation transcript:

1 Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan

2 Introduction

3 Request-Reply Protocols (1)  Low level support for requesting the execution of a remote operation  Direct support for RPC and RMI  Synchronous and reliable communication

4 Request-Reply Protocols (2)

5 Message Identifiers  A request ID  Taken from increasing sequence of integers  Reset to zero when reaches maximum  Unique to the sender  An identifier  Ports and internet addresses of the sender/receiver  Unique in the distributed system

6 Failure Model of Request-Reply Protocol  Implementing doOperation, getRequest and sendRequest over UDP  Omission failures  No guarantee of ordered delivery  Suffering from the failure of processes  Using timeouts by doOperation  Returning with an error message  Sending request message repeatedly  Filtering out duplicate requests (server side)  Keeping record of reply messages (server side)

7 TCP Streams in the Request-Reply Protocol  Problem of determining buffer size in UDP  Limitted length of datagrams for arguments or results in RMI or RPC  TCP allows arguments and results of any size  JAVA object serialization  Stream protocol  Arguments and results sent over streams b/w client and server  Objects of any size to be transmitted reliably

8 HTTP: An example of request-reply protocol  Web servers manage resources implemented as:  Data – text of an HTML page, images  A program – e.g., servlets, or PHP or Python programs  HTTTP protocol specifies  The messages involved in request-reply exchange  Methods  Arguments  Results  Marshalling rules  Content negotiation  Specification of data representation from client‘s side  Authentication  Checking client’s credentials

9 Remote Method Invocation  A calling object invokes a method in a remote object  Commonalities b/w RMI and RPC  Both support programming with interfaces  Both offer a similar level of transparency, i.e., local and remote calls employ the same syntax  Allows the programmer to pass parameters both by value and by reference  Passing references is attractive if the parameter is large or complex  The remote end, on receiving an object reference, can then access this object using remote method invocation, instead of having to transmit the object value across the network

10 Design Issues for RMI (1) The Object Model  Object references  Objects can be accessed via object references  To invoke a method in an object, the object reference and method name are given, together with any necessary arguments  Interfaces  Define types of arguments, return values and exceptions  An object provides an interface if its class that contains code which implements the methods of that interface  Actions  A method invoked by an object in another object  Contains additional information (arguments) needed to carry out the method  The receiver executes the appropriate method and returns control to the invoking object

11 Design Issues for RMI (2) The Object Model  Exceptions  dealing with errors, unexpected conditions, inconsistent values, etc  Failures, attempt to read/write to files or network sockets  Provide a clean way to deal with error conditions without complicating the code  Garbage Collection  The mechanism of freeing the space occupied by objects when no longer needed  Automatic space recovery from objects in Java  Manual method of freeing space in C++

12 Design Issues for RMI (3) Distributed Objects  The state of a program partitioned into separate parts, each associated with an object  Physical distribution of objects into different processes or computers  Replication and migration of objects  To obtain the benefit of fault tolerance, enhanced performance, availability  Client-server  Distributed objects managed by servers  Clients invoke the methods using RMI  Invoking request sent via a message  Invocation carried out by executing a method of the object at the server and returning the results

13 Design Issues for RMI (4) Distributed Object Model  Each process contains a collection of objects  Only local invocations  Both local and remote invocations  Invocations b/w objects in different processes, whether in the same computer or not, are called RMI  Invocations b/w objects in the same process are local

14 Design Issues for RMI (5) Distributed Object Model

15 Design Issues for RMI (6) Actions in a distributed object system  In RMI, remote reference of the object must be available to the invoker  Remote object references may be obtained as the result of RMI  When an object leads to the instantiation of a new object, that object will normally live within the process where the constructor was used  Remote objects with methods of instantiating objects that can be accessed by RMI

16 Implementation of RMI (1)  Communication module  Carry out the request-reply protocol (request & reply messages)  Message type, requestId, remote reference  Dispatches the request to the object’s method from the reference obtained from the request

17 Implementation of RMI (2)  Remote reference module  Translating b/w local and remote object references, creating remote object references  Remote object table to record the correspondence b/w local object references in a process and remote object references

18 Implementation of RMI (3)  Servants  Instance of a class that provides the body of a remote object  Lie within the server process  Handles the remote requests  Created when remote objects are instantiated

19 Implementation of RMI (4)  The RMI Software  A layer of software b/w the application-level objects and the communication and remote reference modules  Proxy Makes RMI transparent to clients Hides the details of remote object reference, marshalling, unmarshalling, sending and receiving of messages

20 Implementation of RMI (5)  The RMI Software  Dispatcher One dispatcher and one skeleton for each class representing a remote object Receives request message from the communication module Uses the operationId to select the appropriate method in the skeleton

21 Implementation of RMI (6)  The RMI Software  Skeleton Class of a remote object has a skeleton, which implements the methods in the remote interface Unmarshals the arguments in the request message and invokes the corresponding method in the servant Waits for the invocation to complete and marshals the results in a reply message to the sending proxy’s method

22 Distributed Garbage Collection  Ensuring the existence of a local or remote reference of an object anywhere in a set of distributed objects  Collecting object and recovering memory  Whenever a remote object reference enters a process, a proxy will be created and will stay there for as long as it is needed  The process where the object lives should be informed of the new proxy at the client  When there is no longer a proxy at the client, the server should be informed


Download ppt "Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan."

Similar presentations


Ads by Google