Java Remote Method Invocation (RMI)

Slides:



Advertisements
Similar presentations
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Advertisements

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.
Remote Method Invocation CS587x Lecture Department of Computer Science Iowa State University.
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
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.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
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 Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology.
Company LOGO Remote Method Invocation Georgi Cholakov, Emil Doychev, University of Plovdiv “Paisii.
FONG CHAN SING (143334) WONG YEW JOON (143388). JAVA RMI is a distributive system programming interface introduced in JDK 1.1. A library that allows an.
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.
DISTRIBUTED FILE SYSTEM USING RMI
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
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
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
CMPT Dr. Alexandra Fedorova Lecture VI: Distributed Objects. Remote Method Invocation.
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.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
1 Java Programming II Java Network II (Distributed Objects in Java)
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
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.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
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.
Silberschatz, Galvin, and Gagne  1999 Applied Operating System Concepts Chapter 15: Distributed Communication Sockets Remote Procedure Calls (RPCs) Remote.
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.
Remote Method Invocation onlineTraining/rmi/RMI.html.
RMI Continued IS Outline  Review of RMI  Programming example.
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.
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.
Presentation: RMI introduction. Goals of this lesson After this 35 min. lesson you will be: Introduced to Java RMI Ready to present RMI’s position in.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
RMI , Naming Service, Serialization and Internationalization Chapter 4
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Florida State UniversityCOP Advanced Unix Programming Remote Method Invocation /rmi/index.html.
Remote Method Invocation A Client Server Approach.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
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.
Netprog Java RMI1 Remote Method Invocation.
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.
Principles of Software Development
Remote Method Invocation
Java RMI CS-328 Internet Programming.
What is RMI? Remote Method Invocation
Remote Method Invocation
Java RMI (more) CS-328 Internet Programming.
Knowledge Byte In this section, you will learn about:
Network and Distributed Programming in Java
Using RMI -The Example of A Remote Calculator
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
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Java Remote Method Invocation (RMI) In Java we implement object systems: JVM 1 JVM 2 distribution scheme thread 1 thread 2 execution scheme O1 O2 O3

Programs/objects running on different virtual machines: separately compiled/linked allocated in different address spaces  object by value message passing Approach: (very natural in object technology) definition of behavior  interface implementation of behavior  class

The concept client object client object server object server object STUB SKELETON server object server object

RMI architecture layers client server stubs & skeletons stubs & skeletons RMI system remote reference layer remote reference layer transport layer

Stubs: plays the role of PROXY Skeletons: helper class: generated automatically (Java 2: new protocol + reflection classes  no skeleton class)

Remote Reference Layer (RRL) RRL defines the invocation semantics Connections: unicast, point-to-point (currently) Stages: server instantiates service exporting to RMI optional: naming and registering (Java 2: activable remote object (i.e. “on-demand instantiation”)

On TCP/IP: Java Remote Method Protocol (JRMP) network cable Transport layer JRE JRE JRE JRE Host OS Host OS Network layer Network layer On TCP/IP: Java Remote Method Protocol (JRMP) Other proprietary protocols are also in use!! (Java 2 v1.3: RMI-IIOP (straight link to CORBA))

The big question: How can a client find a particular service? Naming The big question: How can a client find a particular service? RMI registry lookup register client server stubs & skeletons stubs & skeletons RMI

RMI can use various directory services. RMI includes: rmiregistry service: - the registry service runs on each machine, which hosts remote objects and accepts requests for services - default TCP/IP port: 1099 Client: the RMI registry service provides lookup method specification of required remote object service: URL rmi://<host_name> [:<name_service_port>] /<service_name>

Using RMI Components of an RMI based application: interface definitions for remote services implementations of remote services stub and skeleton files server(s) to host the services RMI naming service client program optional: class file provider Example: remote calculator service and client program

Step 1: write and compile service interfaces import java.rmi.Remote; import java.rmi.RemoteException; public interface Calculator extends Remote { public long add(long a, long b) throws RemoteException; public long sub(long a, long b) throws RemoteException; public long mul(long a, long b) throws RemoteException; public long div(long a, long b) throws RemoteException; }

Step 2: write and compile service implementation import java.rmi.server.UnicastRemoteObject; import java.rmi.RemoteException; public class CalculatorImpl extends UnicastRemoteObject implements Calculator { // Implementations must have an explicit constructor // in order to declare the RemoteException exception public CalculatorImpl() throws RemoteException { super(); } public long add(long a, long b) throws RemoteException { return a + b; public long sub(long a, long b) throws RemoteException { return a - b; public long mul(long a, long b) throws RemoteException { return a * b; public long div(long a, long b) throws RemoteException { return a / b;

Step 3: generate stub and skeleton classes RMI compiler: part of JDK rmic CalculatorImpl Result: CalculatorImpl_Stub.class CalculatorImpl_Skel.class

Step 4: write remote service class import java.rmi.Naming; public class CalculatorServer { public CalculatorServer() { try { Calculator c = new CalculatorImpl(); Naming.rebind("rmi://localhost:1099/CalculatorService", c); } catch (Exception e) { System.out.println("Trouble: " + e); } public static void main(String args[]) { new CalculatorServer();

Step 5: write client program import java.rmi.Naming; import java.rmi.RemoteException; import java.net.MalformedURLException; import java.rmi.NotBoundException; public class CalculatorClient { public static void main(String[] args) { try { Calculator c = (Calculator) Naming.lookup("rmi://localhost/CalculatorService"); System.out.println( c.sub(4, 3) ); System.out.println( c.add(4, 5) ); System.out.println( c.mul(3, 6) ); System.out.println( c.div(9, 3) ); } catch (MalformedURLException murle) { <.. some code here ..> catch (RemoteException re) { <.. some code here ..> catch (NotBoundException nbe) { <.. some code here ..> catch (java.lang.ArithmeticException ae){ <.. some code here ..>

Remarks on parameter passing in RMI Parameters in a single JVM: primitive types: by value object types: “object reference by value” Parameters in RMI: object types: (of course) by value  object serialization local reference to a remote object: reference to the proxy