DISTRIBUTED OBJECTS AND REMOTE INVOCATION 1. 2 Topics  Middleware  Remote Method Invocation  Remote Procedure Call.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

DISTRIBUTED OBJECTS AND REMOTE INVOCATION
RPC Robert Grimm New York University Remote Procedure Calls.
Remote Procedure Call Design issues Implementation RPC programming
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
Remote Method Invocation
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
CORBA Case Study By Jeffrey Oliver March March 17, 2003CORBA Case Study by J. T. Oliver2 History The CORBA (Common Object Request Broker Architecture)
Sockets  Defined as an “endpoint for communication.”  Concatenation of IP address + port.  Used for server-client communication.  Server waits for.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
Remote Procedure Call Chin-Chih Chang. Remote Procedure Call Remote Procedure Call (RPC) is a protocol that allows programs to call procedures located.
Introduction to Remote Method Invocation (RMI)
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
.NET Mobile Application Development Remote Procedure Call.
Slides for Chapter 5: Communication between distributed objects
1 Java Programming II Java Network II (Distributed Objects in Java)
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.
11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors.
Sun RPC also called ONC (Open Network Computing) RPC originally designed for client-server communication for Sun Network File System (NFS) provides an.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
DISTRIBUTED OBJECTS AND REMOTE INVOCATION. Introduction This chapter is concerned with programming models for distributed applications... Familiar programming.
CSE 451: Operating Systems Winter 2015 Module 22 Remote Procedure Call (RPC) Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
IS473 Distributed Systems CHAPTER 5 Distributed Objects & Remote Invocation.
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
Distributed Objects & Remote Invocation
Distributed Objects and Remote Invocation Source: George Colouris, Jean Dollimore, Tim Kinderberg & Gordon Blair (2012). Distributed Systems: Concepts.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Slides for Chapter 5: Distributed objects and remote invocation From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition.
Distributed objects and remote invocation Pages
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
Principles of Software Development
03 – Remote invoaction Request-reply RPC RMI Coulouris 5
Chapter 5 Remote Procedure Call
Remote Method Invocation
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Slides for Chapter 5: Distributed objects and remote invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote method invocation (RMI)
Distribution Infrastructures
Remote invocation (call)
Java Remote Method Invocation
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 1

2 Topics  Middleware  Remote Method Invocation  Remote Procedure Call

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 3 Introduction  Objects that can receive remote method invocations are called remote objects and they implement a remote interface.  Programming models for distributed applications are:  Remote Procedure Call (RPC)  Client calls a procedure implemented and executing on a remote computer  Call as if it was a local procedure

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 4 Introduction  Remote Method Invocation (RMI)  Local object invokes methods of an object residing on a remote computer  Invocation as if it was a local method call  Event-based Distributed Programming  Objects receive asynchronous notifications of events happening on remote computers/processes

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 5 Introduction  Middleware  Software that provides a programming model above the basic building blocks of processes and message passing is called middleware.  The middleware layer uses protocols based on messages between processes to provide its higher-level abstractions such as remote invocation and events. (Figure 1)

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 6 Introduction Figure 1. Middleware layers

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 7 Introduction  Transparency Features of Middleware  Location transparency:  In RMI and RPCs, the client calls a procedeure/method without knowledge of the location of invoked method/procedure.  Transport protocol transparency:  E.g., request/reply protocol used to implement RPC can use either UDP or TCP.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 8 Introduction  Transparency of computer hardware  They hide types of hardware architectures  Transparency of operating system  It provides independency of the underlying operating system.  Transparency of programming language used  E.g., by use of programming language independent Interface Definition Languages (IDL), such as CORBA IDL.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 9 Introduction // In file Person.idl struct Person { string name; string place; long year; } ; interface PersonList { readonly attribute string listname; void addPerson(in Person p) ; void getPerson(in string name, out Person p); long number(); }; CORBA IDL example

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 10 Introduction  Interfaces for RMI and RPC  An explicit interface is defined for each module.  An Interface hides all implementation details.  Accesses the variables in a module can only occur through methods specified in interface.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 11 Introduction  Interface in distributed system  No direct access to remote variables is possible Using message passing mechanism to transmit data objects and variables » Request-reply protocols Specify input, output as attribute to parameters » I nput: transmitted with request message » Output: transmitted with reply message

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 12 Introduction  RPC and RMI interfaces are often seen as a client/server system  Service interface (in client server model) Specification of procedures and methods offered by a server  Remote interface (in RMI model) Specification of methods of an object that can be invoked by objects in other processes

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 13 Introduction  Interface Definition Languages (IDL)  Impossible to specify direct access to variables in remote classes  Hence, access only through specified interface  Desirable to have language-independent IDL that compiles into access methods in application programming language  Example: CORBA IDL (Figure 2) IDL is designed to allow objects implemented in different languages to invoke one-another

DISTRIBUTED OBJECTS AND REMOTE INVOCATION Basic Communication Primitives 14 (Client) doOperation() ….. (wait).. Continue (Client) doOperation() ….. (wait).. Continue (Server) getRequest() Select Object/Procedure Execute Methods Send Reply (Server) getRequest() Select Object/Procedure Execute Methods Send Reply Request Message Reply Message

DISTRIBUTED OBJECTS AND REMOTE INVOCATION External Data Representation & Marshalling  Information stored in running program is represented as data structure  In the form of communication, data structure is converted to sequence of bytes, it may be data values of many types  While exchanging data:  The data structure is converted to an agreed external format (eg ASCII, BASE64) before transmission and converted to local on receipt

DISTRIBUTED OBJECTS AND REMOTE INVOCATION External Data Representation & Marshalling  An agreed standard for the representation of data structure and primitive values is called an external data representation  Marshalling:  Is the process of taking a collection of data items & assembling them into a form suitable for transmission  Un-marshalling:  Is the process of disassembling them on arrival to produce an equivalent collection of data items at destination

DISTRIBUTED OBJECTS AND REMOTE INVOCATION Remote Method Invocation (RMI) Click to PDF 17

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 18 Java RMI  Java RMI extends the Java object model to provide support for distributed objects in the Java language.  It allows object to invoke methods on remote objects using the same syntax as for local invocation.  It is a single language system – remote interfaces are defined in the Java language.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 19 Java RMI An object making a remote invocation needs to be able to handle RemoteExceptions that are thrown in the event of communication subsystem failures A remote object must implement Remote interface. The next example is a simple Hello world program that is implemented in Java RMI

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 20 Java RMI- Example 1  This example is from java.sun.com for more explanation see the site:  In this example we do the followings:  Define the remote interface  Implement the server  Implement the client  Compile the source files  Start the Java RMI registry, server, and client

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 21 Java RMI Hello.java - a remote interface import java.rmi.Remote; import java.rmi.RemoteException; public interface Hello extends Remote { String sayHello() throws RemoteException; }

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 22 Java RMI // Implement the server import java.rmi.registry.LocateRegistry; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class Server implements Hello { public Server() {} public String sayHello() { return "Hello, world!"; }

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 23 Java RMI public static void main(String args[]) { try { Server obj = new Server(); Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0); // Bind the remote object's stub in the registry Registry registry = LocateRegistry.getRegistry(); registry.bind("Hello", stub); System.err.println("Server ready"); } catch (Exception e) { System.err.println("Server exception: " + e.toString()); e.printStackTrace(); }

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 24 Java RMI // Implement the client import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; public class Client { private Client() {}

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 25 Java RMI public static void main(String args[]) { String host = (args.length < 1) ? null : args[0]; try { Registry registry = LocateRegistry.getRegistry(host); Hello stub = (Hello) registry.lookup("Hello"); String response = stub.sayHello(); System.out.println("response: " + response); } catch (Exception e) { System.err.println("Client exception: " + e.toString()); e.printStackTrace(); }

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 26 Java RMI  The source files for this example can be compiled as follows:  javac Hello.java Server.java Client.java  Start the Java RMI registry : rmiregistry  Start the Server: java Server  Start the Client: java Client

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 27 Java RMI  RMIregistry  The RMIregistry is the binder for Java RMI.  The RMIregistry runs on every server that hosts remote objects.  It maps local object names of the form //computerName:port/objName to object references.  Clients need to query a particular host to get reference.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 28 Java RMI Figure 9. Classes supporting Java RMI  Figure 9 shows the inheritance structure of the classes supporting Java RMI servers.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION  Run RMI on Eclipse  step-implementation-tutorial-for-java-rmi step-implementation-tutorial-for-java-rmi  JAVA RMI Implementation Tutorial steps  step-implementation-tutorial-for-java-rmi step-implementation-tutorial-for-java-rmi  rint_server.html rint_server.html  Practice yourself from this link using java eclipse 29

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 30 Remote Procedure Call (RPC) A remote procedure call (RPC) is similar to a remote method invocation (RMI). A client program calls a procedure in another program running in a server process. RPC is generally implemented over a request- reply protocol. The software that support RPC is shown in Figure 3.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 31 Remote Procedure Call (RPC) Figure 3. Role of client and server stub procedures in RPC in the context of a procedural language

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 32 Remote Procedure Call (RPC) RPC only addresses procedure calls. RPC is not concerned with objects and object references. A client that accesses a server includes one stub procedure for each procedure in the service interface. A client stub procedure is similar to a proxy method of RMI. A server stub procedure is similar to a skeleton method of RMI.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION RPC Execution Client Routine Client Stub Network Routines Server Routine Server Stub Network Routines

DISTRIBUTED OBJECTS AND REMOTE INVOCATION RPC execution 1.The client calls local procedures (client Stub), the stub packages the arguments for the remote procedure and create more network messages (marshalling) 2.The client stub send MSG to the remote system via system call at the local kernel 3.The connection oriented/less protocol transfers the MSG to the remote system (RR Protocol). 4.The server stub procedure unmarshals the arguments of MSG and converts them 34

DISTRIBUTED OBJECTS AND REMOTE INVOCATION RPC execution 5.Server Stub executes a local procedure call to invoke actual server function passing it the argument that it received from the argument client stub. 6.When server procedure is executed, it sends return values to server stub. 7.The server stub converts the return values, marshal them into one or more MSG and send them back to client 8.Messages are sent back to client stub 9.Client stub reads the network MSG from local kernel. 10.Client stub returns to another function call 35

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 36 RPC Example 1: Local Program * A first program (hello.c) to test rpc. Use of this program is for * testing the logic of the rpc programs. #include int main (void) { static char * result; static char msg[256]; printf("getting ready to return value\n"); strcpy(msg, "Hello world"); result= msg; printf("Returning %s\n", result); return (0); } /

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 37 Protocol Definition Program The name of this program is hello.x The number at the end is version number and should be updated each time the service is updated to make sure the active old copies is not responding to the client program. program HELLO { version ONE{ string PRINT_HELLO() = 1; } = 1 ; } = 0x ;

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 38 Client Program Now we are ready to use rpcgen (command for generating the required programs). Note that so far we have only hello.c and hello.x After running “rpcgen -a -C hello.x” the directory contain following files: -rw-rw-r-- 1 aabhari aabhari 131 Oct 5 12:15 hello.c -rw-rw-r-- 1 aabhari aabhari 688 Oct 5 12:19 hello.h -rw-rw-r-- 1 aabhari aabhari 90 Oct 5 12:18 hello.x -rw-rw-r-- 1 aabhari aabhari 776 Oct 5 12:19 hello_client.c -rw-rw-r-- 1 aabhari aabhari 548 Oct 5 12:19 hello_clnt.c -rw-rw-r-- 1 aabhari aabhari 316 Oct 5 12:19 hello_server.c -rw-rw-r-- 1 aabhari aabhari 2076 Oct 5 12:19 hello_svc.c The two templates that we should modify for this example are hello_client.c and hello_server.c.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 39 Template of hello_client Program * This is sample code generated by rpcgen. * These are only templates and you can use them as a guideline for developing your own functions. #include "hello.h" void hello_1(char *host) { CLIENT *clnt; char * *result_1; char *print_hello_1_arg;

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 40 Template of hello_client Program #ifndef DEBUG clnt = clnt_create (host, HELLO, ONE, "udp"); if (clnt == NULL) { clnt_pcreateerror (host); exit (1); } #endif /* DEBUG */ result_1 = print_hello_1((void*)&print_hello_1_arg, clnt); if (result_1 == (char **) NULL) { clnt_perror (clnt, "call failed"); } #ifndef DEBUG clnt_destroy (clnt); #endif /* DEBUG */ }

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 41 Template of hello_client Program Int main (int argc, char *argv[]) { char *host; if (argc < 2) { printf ("usage: %s server_host\n", argv[0]); exit (1); } host = argv[1]; hello_1 (host); exit (0); }

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 42 hello_client Program  We have to modifiy hello_client template program.  The modifications for our first example are very simple.  Next slides show the modified program of hello_client that needs only few lines.

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 43 hello_client Program * This is sample code generated by rpcgen. * These are only templates and you can use them as a guideline for developing your own functions. #include "hello.h" #include void hello_1(char *host) { CLIENT *clnt; char * *result_1; char *print_hello_1_arg;

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 44 hello_client Program #ifndef DEBUG clnt = clnt_create (host, HELLO, ONE, "udp"); if (clnt == NULL) { clnt_pcreateerror (host); exit (1); } #endif /* DEBUG */ result_1 = print_hello_1((void*)&print_hello_1_arg, clnt); if (result_1 == (char **) NULL) clnt_perror (clnt, "call failed"); else printf(" from server: %s\n",*result_1); #ifndef DEBUG clnt_destroy (clnt); #endif /* DEBUG */ }

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 45 hello_client Program Int main (int argc, char *argv[]) { char *host; if (argc < 2) { printf ("usage: %s server_host\n", argv[0]); exit (1); } host = argv[1]; hello_1 (host); exit (0); } //end clinet_server.c

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 46 Template of hello-server Program * This is sample code generated by rpcgen. * These are only templates and you can use them as a guideline for developing your own functions. #include "hello.h" char ** print_hello_1_svc(void *argp, struct svc_req *rqstp) { static char * result; /* insert server code here */ return &result; }

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 47 hello-server Program * This is sample code generated by rpcgen. * These are only templates and you can use them as a guideline for developing your own functions. #include "hello.h" char ** print_hello_1_svc(void *argp, struct svc_req *rqstp) { static char * result; static char msg[256]; printf("getting ready to return value\n"); strcpy(msg, "Hello world"); result= msg; printf("Returning\n"); return &result; }

DISTRIBUTED OBJECTS AND REMOTE INVOCATION 48 Making Client and Server Program To compile the client leda% gcc hello_client.c hello_clnt.c -o client -lnsl To compile the server leda% gcc hello_server.c hello_svc.c -o server -lnsl To run the server use leda%./server To run the client use elara%./client leda