Remote method invocation (RMI)

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

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.
Distributed Object & Remote Invocation Vidya Satyanarayanan.
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.
Introduction to Remote Method Invocation (RMI)
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Internet Software Development Remote Method Invocation Paul Krause.
Slides for Chapter 5: Communication between distributed objects
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
+ A Short Java RMI Tutorial Usman Saleem
CS425 /CSE424/ECE428 – Distributed Systems – Fall Nikita Borisov - UIUC1 Material derived from slides by I. Gupta, M. Harandi, J. Hou, S.
Communication between distributed objects Remote procedure call
Information Management NTU Interprocess Communication and Middleware.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
Java RMI: Remote Method Invocation January 2000 Nancy McCracken Syracuse University.
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.
RMI RMI is the java API that facilitate distributed computing by allowing remote method calls. A remote method call represents a method invocation between.
Lecture 5: RPC and Distributed Objects Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
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.
Distributed Objects and Middleware. Sockets and Ports Source: G. Coulouris et al., Distributed Systems: Concepts and Design.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Slides for Chapter 17: CORBA Case Study From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley 2001.
DISTRIBUTED OBJECTS AND REMOTE INVOCATION. Introduction This chapter is concerned with programming models for distributed applications... Familiar programming.
IS473 Distributed Systems CHAPTER 5 Distributed Objects & Remote Invocation.
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
1 Distributed Objects and Remote Invocation – 5.1 Introduction  Foci: –Communication among distributed objects via RMI  Recipients of remote invocations.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Slides for Chapter 5: Distributed objects and remote invocation From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition.
Remote Method Invocation A Client Server Approach.
Distributed objects and remote invocation Pages
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Remote Method Invocation RMI architecture stubs and skeletons for remote services RMI server and client in Java Creating an RMI Application step-by- step.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
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.
Java Distributed Computing
Chapter 4 Remote Method Invocation
Communication between distributed objects Remote procedure call
Java Distributed Computing
RMI Packages Overview java.rmi java.rmi.server java.rmi.registry
Remote Method Invocation
What is RMI? Remote Method Invocation
Communication between distributed objects Remote procedure call
Remote Method Invocation
Edition 5, © Addison-Wesley 2012
Distributed Systems Course Topics in distributed objects
Programming Models for Distributed Application
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Creating a Distributed System with RMI
Slides for Chapter 5: Distributed objects and remote invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Creating a Distributed System with RMI
Creating a Distributed System with RMI
Remote Method Invocation
Distribution Infrastructures
Creating a Distributed System with RMI
Remote invocation (call)
CS 584 Lecture 18 Assignment Glenda assignment extended to the Java RMI Deadline No Java RMI Assignment Test Friday, Saturday, Monday.
Java Remote Method Invocation
Creating a Distributed System with RMI
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Remote method invocation (RMI)

معایب فراخوانی رویه راه دور: فضای کمی برای کد عدم استقلال از زبان روشی نقطه به نقطه مدل مشتری و سرور و نه همتا به همتا راه حل : استفاده از اشیاء توزیع شده

سه مدل اشیاء توزیع شده معروف: CORBA : معماری عمومی مستقل از زبان و سیستم عامل DCOM : از مایکروسافت و وابسته به ویندوز ولی مستقل از زبان RMI : مستقل از سیستم عامل ولی وابسته به زبان جاوا

Remote method invocation (RMI) Related to RPC but extended into the world of distributed objects In RMI, a calling object can invoke a method in a remote object Underlying details are hidden from the user Commonalities (RMI, RPC) are: They both support programming with interfaces They both typically constructed on top of request-reply protocols and can offer a range of call semantics They both offer a similar level of transparency

Remote and local method invocations (RMI) B C D E F

Fundamental concepts are heart of the distributed object: Remote object references: Objects can invoke the methods of a remote object, access to its remote object reference Remote interfaces: Remote object has remote interface, specifies its methods can invoked remotely Action: is initiated by an object invoking a method in another object, invocation of a method can have three effects: State of the receiver be changed New object may be instantiated Further invocations on methods in other objects

RMI A remote object and its remote interface Data implementation object { of methods reference

Implementation of RMI The role of proxy and skeleton in remote method invocation

RMI (modules) Communication module: Do request-reply protocol (transmits request and reply messages) Specified invocation semantics, for example at-most-once In the server selects the dispatcher Remote reference module: Translating between local and remote object references For creating remote object references Remote object table that records the correspondence between local and remote object references, table includes: an entry for all remote objects held by the process in table at the server, an entry for each local proxy in the table at the client

RMI (modules) Servants: An instance of a class that provides the body of a remote object Handles the remote requests passed on by the corresponding skeleton Live within a server Created when remote objects are instantiated and remain in use until No longer needed being deleted

RMI Software RMI software consists of a layer of software between the application objects and communication and remote reference modules, roles of it are as follows (Proxy, Dispatcher, Skeleton) Proxy: Make remote method invocation transparent to clients by behaving like a local object Dispatcher: One dispatcher and one skeleton for each class representing a remote object, Uses operationId to select the appropriate method in the skeleton

Skeleton: Each class of a remote object has a skeleton Implemented quite differently from the methods in the servant Skeleton unmarshals the arguments in the request message and invokes the corresponding method in the servant Marshals the result, together with any exceptions, in reply message

Classes for the proxy, dispatcher and skeleton used in RMI are generated automatically by an interface Compiler: In CORBA, interfaces of remote objects are defined in CORBA IDL, and the interface compiler can be used to generate the classes proxies, dispatchers and skeletons in C++ or Java In Java RMI, the set of methods offered by a remote object is defined as a Java interface. Java RMI compiler generates the proxy, dispatcher and skeleton classes

Binder: Client require, obtaining a remote object reference for remote objects in server Binder is separate service that maintains a table mappings from names to remote object references By servers to register their remote objects by name By clients to look them up CORBA Naming Service Java binder, RMIregistry

Java Remote interfaces Shape and ShapeList Remote interfaces are defined by extending an interface called Remote provided in the java.rmi package. import java.rmi.*; import java.util.Vector; public interface Shape extends Remote { int getVersion() throws RemoteException; GraphicalObject getAllState() throws RemoteException; 1 } public interface ShapeList extends Remote { Shape newShape(GraphicalObject g) throws RemoteException; 2 Vector allShapes() throws RemoteException;

RMIregistry RMIregistry is the binder for Java RMI An instance of RMIregistry should normally run on every server computer It maintains a table mapping, URL-style names to references to remote objects hosted on computer Is accessed by methods of the Naming class, whose methods take as an argument a URL-formatted string of the form: //computerName:port/objectName

Java RMIregistry The methods of the Naming class void rebind (String name, Remote obj) This method is used by a server to register the identifier of a remote object by name void bind (String name, Remote obj) This method can alternatively be used by a server to register a remote object by name, but if the name is already bound to a remote object reference an exception is thrown. void unbind (String name, Remote obj) This method removes a binding. Remote lookup(String name) This method is used by clients to look up a remote object by name. A remote object reference is returned. String [] list() This method returns an array of Strings containing the names bound in the registry.

  مثال: اینترفیس سرور import java.rmi.*; public interface NameCollections extends Remote //Remote Interface { public String getName (int index) throws RemoteException; //Remotely Accessible Method\ }

کلاسی که این اینترفیس را در سرور پیاده‌سازی میکند   کلاسی که این اینترفیس را در سرور پیاده‌سازی میکند import java.rmi.*; import java.util.*; import java.rmi.server.*; class NameStorage extends UnicastRemoteObject implements NameCollections { //A Class That Implements The Remote Interface private Map name; public NameStorage () throws RemoteException{ name=new HashMap(); name.put(1,"iman"); name.put(2,"reihanian"); } public String getName (int index)throws RemoteException{ String str=name.get(new Integer(index)); return str;

در ادامه پیاده سازی RMI در سرور import java.rmi.*; import javax.naming.*; class NameServer { public static void main (String args[]) throws RemoteException,NamingException { Context ictxt=new InitialContext(); NameStorage store=new NameStorage(); ictxt.bind("rmi:Storage",store); //Binding The Remote Object(store) With A Name(storage) System.out.println("Clients can invoke the methods...."); }

قسمت کلاینت import java.rmi.*; import java.util.*; import javax.naming.*; class NameClient { public static void main (String args[]) throws NamingException,RemoteException { Context itxt=new InitialContext(); //Searching For The Remote Object In The RMI registry NameCollections coll= (NameCollections) itxt.lookup("rmi://localhost/Storage"); String n1=coll.getName(2);// Invoking The Remote Method System.out.println("Name Obtained from the server:" + n1); }