Remote Method Invocation

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
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.
Company LOGO Remote Method Invocation Georgi Cholakov, Emil Doychev, University of Plovdiv “Paisii.
Changing the way of designing distributed applications Communication oriented design: FIRST design the communication protocol for the distributed system.
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.
J2ME RMI 1 Java 2 Platform, Micro Edition Implementation of J2ME RMI Application Farooq Sheikh.
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.
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
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
Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.
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.
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.
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets Rethinking out tic-tac-toe game.
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.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
Java Remote Method Invocation (RMI) ). Distributed Systems  a collection of independent computers that appears to its users as a single coherent system.
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.
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.
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.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Proxy Pattern. What’s a Proxy? A remote proxy acts as a local representative of a remote object Remote Object: instantiated in a different JVM heap (a.
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.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
Netprog Java RMI1 Remote Method Invocation.
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.
Remote Method Invocation. Introduction What is Remote Method Invocation? Remote method invocation allows objects residing in one JVM execute methods.
Java Distributed Computing
Principles of Software Development
Java Distributed Computing
Java Remote Method Invocation (RMI)
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
Chapter 40 Remote Method Invocation
Remote method invocation (RMI)
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
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
Software Design Lecture : 38.
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Remote Method Invocation

Introduction Remote Method Invocation (RMI) is a distributed systems technology that allows one JVM to invoke object methods that will be run on another JVM located elsewhere on a network. This technology is very important for the development of large-scale systems, as it makes it possible to distribute resources and processing load across more than one machine.

RMI is a Java technology that allows one JVM to communicate with another JVM and have it execute an object method. Using RMI, objects can invoke methods on other objects located remotely as easily as if they were on the local host machine.

Object main(String[ ] args) Method request RemoteObject method1(…) Java Virtual Machine Object main(String[ ] args) Method request Java Virtual Machine RemoteObject method1(…) method2(…) Method response

Each RMI service is defined by an interface, which describes object methods that can be executed remotely. This interface must be shared by all developers who will write software for that service. More than one implementation of the interface can be created, and developers do not need to be aware of which implementation is being used or where it is located.

How Does RMI Work? Systems that use RMI for communication typically are divided into two categories: Servers A server provides an RMI service Clients A client invokes object methods of this service.

RMI servers must register with a lookup service, to allow clients to find them, or they can make available a reference to the service in some other way. The Java platform includes an application called rmiregistry (which runs as a separate process). This application allows other applications to register RMI services or obtain a reference to a named service.

Each service registration is associated with a name to allow clients to select the appropriate service. If a service is moved to another server, the client need only look up the registry again to find the new location. RMI REGISTRY RMI Server RMI Server RMI Server

Once a server has registered, it will then wait for incoming RMI requests from clients.

RMI clients will send RMI messages to invoke an object method remotely RMI clients will send RMI messages to invoke an object method remotely. However, a client must first obtain a reference for the remote object which is normally done by looking up a service in the RMI registry. The client requests a particular service name, and receives a URL to the remote resource. The URL has the following format: rmi://hostname:port/servicename

Once an object reference is obtained, the client can then interact with the remote service. The networking details of requests are completely transparent to the application developer. This is achieved through a division of the RMI system into two components i.e. the stub and the skeleton.

The stub object acts as a proxy object, conveying object requests to the remote RMI server. It implements a particular RMI interface, which the client application can use just like any other object implementation. When the stub object receives a request, it passes a message to a remote RMI service, waits for a response, and returns the response to the calling method.

Hence, the application developer need not be concerned about where the RMI resource is located, on which platform it is running, or how it will fulfill the request. The RMI client simply invokes a method of the proxy object which handles all the implementation details.

stub object somemethod(…) request skeleton object response RMI client application stub object somemethod(…) request RMI server skeleton object somemethod(…) response

At the RMI server end, the skeleton object is responsible for listening for incoming RMI requests and passing these on to the RMI service. Note that the skeleton object does not provide an implementation of an RMI service. It only acts as a receiver of requests and passes these requests on further to the actual implementation object that implements the RMI interface. The implementation object executes the appropriate method and pass the results back to the stub object in the RMI client.

TCP sockets are used in the communication that occurs between stub and skeleton.

LightBulb Example: Defining an RMI Service Interface Any system that uses RMI will use a service interface. An RMI service interface defines the object methods that can be invoked remotely. Stub and skeleton objects, as well as the RMI service, must implement this interface.

All RMI service interfaces extend the java.rmi.Remote interface. Only methods defined in a java.rmi.Remote interface (or its subclasses) may be executed remotely - other methods of an object are hidden from RMI clients.

Example: Note that remote methods must be declared as "throws java.rmi.RemoteException" as network errors might occur during communication. import java.rmi.*; public interface RMILightBulb extends Remote { public void on() throws RemoteException; public void off() throws RemoteException; public boolean isOn() throws RemoteException; }

LightBulb Example: Implementing an RMI Service Interface Once a service interface is defined, the next step is to implement it. The implementation not only implements each method in the RMI interface but can also define additional methods. However, only those methods defined in the RMI interface will be accessible remotely. RMILightBulbImpl.java

LightBulb Example: Creating Stub and Skeleton Classes Stub and skeleton classes are responsible for dispatching and processing RMI requests. Developers should not write these classes. They should be generated using the rmic tool provided in the JDK. Compile the RMI interface and implementation. Run the rmic tool as follows: rmic RMILightBulbImpl

Two files will be produced: RMILightBulbImpl_Stub.class RMILightBulbImpl_Skeleton.class

LightBulb Example: Creating an RMI Server The RMI server is responsible for creating an instance of a service implementation and then registering it with the RMI registry. LightBulbServer.java

LightBulb Example: Creating an RMI Client An RMI client needs to obtain an object reference to the remote interface, and doesn't need to be concerned with how messages are sent or received or the location of the service. To find the service initially, a lookup in the RMI registry is made, and after that, the client can invoke methods of the service interface just as if it were a local object. LightBulbClient.java

LightBulb Example: Running the RMI System The following steps should be followed: Copy all necessary files to a directory on the local file system of all clients and the server. Check that the current directory is included in the classpath, or an alternate directory where the classes are located. Change to the directory where the files are located, and run the rmiregistry command. Run the RMI server: java LightBulbServer Run the RMI client: java LightBulbClient