Remote Object Invocation Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
RMI Varun SainiYing Chen. What is RMI? RMI is the action of invoking a method of a remote interface on a remote object. It is used to develop applications.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
Remote Method Invocation CS587x Lecture Department of Computer Science Iowa State University.
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.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Remote Method Invocation
Remote Object 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.
Java RMI. What is RMI? RMI is an RPC system for an object based language. Objects provide a natural granularity for the binding of functions. –RMI allows.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Introduction to Remote Method Invocation (RMI)
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
Communication in Distributed Systems –Part 2
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
Internet Software Development Remote Method Invocation Paul Krause.
1 Distributed Objects Naim R. El-Far, PhD Candidate TA for SEG3202 Software Design and Architecture with N. El- Kadri (Summer 2005) Tutorial 3 of 4 – 10/6/2005.
1 Java Programming II Java Network II (Distributed Objects in Java)
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W
1 Chapter 2. Communication. STEM-PNU 2 Layered Protocol TCP/IP : de facto standard Our Major Concern Not always 7-layered Protocol But some other protocols.
Communication Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology.
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
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.
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.
Abhishek Bachchan Vishal Patangia
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved TDTS04 Föreläsning.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Remote Method Invocation A Client Server Approach.
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.
Khoa CNTT 1/37 PHẠM VĂN TÍNH   Java RMI (Remote Method Invocation)
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Distributed programming in Java Faculty:Nguyen Ngoc Tu Session 5 - RMI.
1 Chapter 2. Communication. STEMPusan National University STEM-PNU 2 Layered Protocol TCP/IP : de facto standard Our Major Concern Not always 7-layered.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
Netprog Java RMI1 Remote Method Invocation.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Computer Science Lecture 4, page 1 CS677: Distributed OS Last Class: RPCs RPCs make distributed computations look like local computations Issues: –Parameter.
Using RMI The Example of A Remote Calculator 1. Parts of A Working RMI System A working RMI system is composed of several parts. –Interface definitions.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
January 26, Ann Wollrath Copyright 1999 Sun Microsystems, Inc., all rights reserved. Java ™ RMI Overview Ann Wollrath Senior Staff Engineer Sun Microsystems,
Java Remote Method Invocation (RMI)
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
DISTRIBUTED COMPUTING
Chapter 40 Remote Method Invocation
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Java Remote Method Invocation
Presentation transcript:

Remote Object Invocation Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology

Outline Distributed objects – Binding client to object – Static vs Dynamic – Parameter passing Examples – Java RMI

Why object-oriented ?  OO has strong features  information hiding  data abstraction  encapsulation  modularity  polymorphism  and inheritance OOP software engineering Modelling Design Language Database Scripting …

Enhancement of RPC RPC – simple – effective – standard for communication in distributed system development Object Oriented + Remote Procedure Call = Remote Object Invocation

Distributed object model (1) Client OS Client ServerOS Server Client invokes a method Skeleton invokes same method at object Client machineServer machine Proxy Network Proxy same interface as object Marshalled invocation passed across network Skeleton interface object state method

Distributed object model (2) When a client binds to a distributed object, load the interface (“proxy”) into client address space – Proxy analogous to stubs Server stub is referred to as a skeleton

Characteristics for distributed objects (1) Compile time vs runtime objects – compile time objects: related to language-level objects Object = instance of a class Interfaces compiled into client, server’s stubs Drawback: depend strongly on particular programming language – runtime objects: how object implemented left open need an adapter to bind dynamically invocation to implementation

Characteristics for distributed objects (2) Persistent vs transient objects – persistent objects: not depend on server process object can be stored in secondary storage if server exits and restored when new server started – transient objects: exists as long as server managing it

Binding client to object Distributed object model provides systemwide reference – can be passed as parameters Binding needed before invoking methods – In practice, binding temporarily creates proxy – 2 approaches Implicit binding Explicit binding

Implicit vs Explicit bindings Implicit Distr_object *obj_ref; obj_ref =...; obj_ref->do_something(); Explicit Distr_object *obj_ref; Local_object *obj_ptr; obj_ref =...; obj_ptr = bind( obj_ref ); obj_ptr->do_something(); Explicit bind and get a pointer to proxy Invoke a method on local proxy

Object reference implementation issuses (1) Goal: to allow client binding to an object Simple approach – reference = (network address, server ID, object ID) – server ID = port (in practice) Drawbacks – what happens if server machine crashes, and the server has a new server ID ? Client can contact with a service to provide mapping between server ID and server The server must register with the service

Object reference implementation issuses (2) Drawbacks – what happens if the server moved to other machine ? a server to provide a mapping, called location server reference = (location server address, systemwide server ID)

Remote Method Invocation Similar to RPC, but has an advantages of systemwide object reference static invocation: – predefined interface definition – interface known when client being developed fobject.append(int) dynamic invocation: – select at runtime which method to be invoked at remote object invoke( fobject, id(append), int)

Passing object references (local & remote) local object O1remote object O2 copy of O1 copy of R1 to O2 server code (method implementation) remote reference R1 new local reference remote invocation with L1 and R1 as parameters client code with RMI to server at C local reference L1 machine Amachine B machine C

DCE Distributed object model Dynamic (private) object client #1client #2client #3 named (shared) object remote reference server machine Distributed dynamic objectsDistributed named objects object created for individual client a function “ create() ” to new an object object not for a single client client looks up named object at directory service

Java RMI Java RMI allows programmer to execute remote function class using the same semantics as local functions calls Local Machine (Client) SampleServer remoteObject; int s; … s = remoteObject.sum(1,2); System.out.println(s); Remote Machine (Server) public int sum(int a,int b) { return a + b; } 1,2 3

Java RMI architecture The server must first bind its name to the registry The client lookup the server name in the registry to establish remote references. The Stub serializing the parameters to skeleton, the skeleton invoking the remote method and serializing the result back to the stub.

Naming service (1) Directory that associates names to remote objects (bind) server machine Remote Object C Remote Object A Remote Object B Naming “X” “Y” “Z”

Naming service (2) Client use Naming Service to find a particular Server object (lookup) client machineserver machine Object Client Remote Object Server Naming “X” “Y” “Z” lookup(“Y”) Remote reference to Server

Steps for Developing an RMI System 1. Define the remote interface 2. Develop the remote object by implementing the remote interface. 3. Develop the client program. 4. Compile the Java source files. 5. Generate the client stubs and server skeletons. 6. Start the RMI registry. 7. Start the remote server objects. 8. Run the client

Server /* SampleServerImpl.java */ public static void main(String args[]) { try { System.setSecurityManager(new RMISecurityManager()); //set the security manager //create a local instance of the object SampleServerImpl Server = new SampleServerImpl(); //put the local instance in the registry Naming.rebind("SAMPLE-SERVER", Server); System.out.println("Server waiting....."); } catch (java.net.MalformedURLException me) { System.out.println("Malformed URL: " + me.toString()); } catch (RemoteException re) { System.out.println("Remote exception: " + re.toString()); } }

Client import java.rmi.*; import java.rmi.server.*; public class SampleClient { public static void main(String[] args) { // set the security manager for the client System.setSecurityManager(new RMISecurityManager()); //get the remote object from the registry try { System.out.println("Security Manager loaded"); String url = "//localhost/SAMPLE-SERVER"; SampleServer remoteObject = (SampleServer)Naming.lookup(url); System.out.println("Got remote object"); System.out.println(" = " + remoteObject.sum(1,2) ); } catch (RemoteException exc) { System.out.println("Error in lookup: " + exc.toString()); } catch (java.net.MalformedURLException exc) { System.out.println("Malformed URL: " + exc.toString()); } catch (java.rmi.NotBoundException exc) { System.out.println("NotBound: " + exc.toString()); }