Remote Method Invocation A Client Server Approach.

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.
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.
Remote Method Invocation in Java Bennie Lewis EEL 6897.
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
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.
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
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.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
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,
Internet Software Development Remote Method Invocation Paul Krause.
RMI Components java.rmi: client-side RMI classes, interfaces, and exceptions java.rmi.server: server-side RMI classes, interfaces, and exceptions java.rmi.registry:
1 Java Programming II Java Network II (Distributed Objects in Java)
+ 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 RMI: Remote Method Invocation January 2000 Nancy McCracken Syracuse University.
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.
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.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
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.
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.
Java Distributed Object Model A remote object is one whose methods can be invoked from another JVM on a different host. It implements one or more remote.
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.
Chapter 4 Remote Method Invocation
Java Remote Method Invocation (RMI)
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
Creating a Distributed System with RMI
Chapter 40 Remote Method Invocation
Creating a Distributed System with RMI
Overview of RMI Architecture
Remote Method Invocation
Creating a Distributed System with RMI
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Java Remote Method Invocation
Creating a Distributed System with RMI
Overview of RMI Architecture
Presentation transcript:

Remote Method Invocation A Client Server Approach

Distributed Object Technologies It aims at location transparency which involves followings- Locating & loading remote classes Locating remote objects and providing a reference to them Enabling remote method calls Notifying programs of network failures and other problems.

RMI for distributed computing RMI is a simple method used for developing and deploying distributed applications in Java environment. RMI enables a programmer to create distributed Java applications, in which methods of remote java objects can be called from other java virtual machines either on same host or on different host scattered across the network.

Cont…….. A call to remote object using RMI is same as a call to local object except- An object passed as a parameter to a remote method or returned from the method must be serializable or be another Remote object. An object passed as a parameter to a remote method or returned from the remote method called is passed by value and not by reference with the exception when a remote object is passed to a remote method or when a remote object is returned by remote method i.e. remote objects are passed by reference. A client always refers to a remote object through one of Remote interfaces that it implements.

Cont….. java.rmi and java.rmi.server packages contain the interfaces and classes that define java RMI system.

RMI Architecture It consists of 4 layers: Application, Stub/Skeleton, Remote Reference and Transport Layer.

Client ApplicationServer Application Stub Skeleton Remote Reference Layer Remote Reference Layer Transport Layer

RMI Architecture Remote method invocation is made through a reference to a remote object. When a client makes a call to a remote method, that client receives a reference to the remote object which implements the remote method. The remote object is not sent over the network to the client. A stub which is client side proxy for the remote object is placed which is responsible for data transfer between local (client) system and the remote (server) system.

Cont…… Many clients may have references to a single remote object. Each of these clients will have their own stub objects representing the remote object but the remote object will not be replicated. The stub object interacts with server side proxy object called skeleton which is responsible for transferring method calls and data between a stub and the actual object being referenced on server.

Application Layer Any application that needs to make some of its methods for remote clients must first be declared in an interface that extends java.rmi.Remote. It is a just a flag an object as being remotely accessible. Remote methods must be declared as public. All remote objects must extend the UnicastRemoteObject which provides functionality for remote accessing. The class UnicastRemoteObject belongs to java.rmi.Server. The Server application must register itself with name server or registry. The client uses this to make first contact with server application and obtain a reference to its remote objects.

Proxy Layer It consists of Stub class and Skeleton class. These are generated using RMI compiler.

Remote Reference Layer It is an abstraction between the stub and skeleton classes and the actual communication protocols that are handled by the transport layer.

Transport layer (TL) It is responsible for actual machine to machine communication. By default communication take place via TCP/IP. When TL receives a request from client side RRL, it locates the RMI server for the remote object that is been requested. Then TL establishes a socket connection to the server. After that, TL passes the established connection to client side RRL and add reference to remote object. The TL monitors the “liveness” of connection. The timeout period is 10 minutes.

RMI Registry Service In any distributed application the client application first locate the remote object. For this, RMI provides a registry service or name service. The registry keeps track of the addresses of the remote objects that are being exported by their applications. All objects are assigned unique names that are used to identify them. Applications can add, remove and access remote objects by calling methods from java.rmi.registry.Registry interface or from rmi.Naming class.

Creating RMI Application

1. Define interface for Remote Classes An interface is created that contains all the methods that the remote object must support. All such interfaces must extend Remote interface. Include throws RemoteException in methods. import java.rmi.*; interface MethodImpl extends Remote { double getSqrt(double dbl) throws RemoteException; }

2. Implement the interface in Server application The server application extends UnicastRemoteObject class and implements the remote interface inside the class. Class RMIServer extends UnicastRemoteObject implements MethodImpl { // server side code }

3. Binding Objects to a Registry Service For an application to bind or register an object with the registry both the registry service as well as application must be running on same machine. An application can bind any object which either extend UnicastRemoteObject or Remote interface. No two objects can be registered with same name. java.rmi.Naming class has 2 methods bind(URL,Ref) URL specifies the location of registry along with name that objects will be registered as. Ref is a reference to the object that is being registered. rebind(URL,Ref) It’ll never throw AlreadyBoundException.

4. Creating Stub & Skeleton Classes Use RMIC compiler which comes along with JDK. rmic It creates- ServerClassName_Stub.class ServerClassName_Skeleton.class

5. Create & Compile Client Program Obtaining a reference to a remote object is accomplished by making a call to the lookup(URL) method of java.rmi.Naming class. On failure it throws a NotBoundException. The lookup() returns an object of java.rmi.Remote and hence must be cast to the type of object the client application expects.

6. Install files on client and server machine On Server machine- Server_stub.class, Server_skel.class, Interface.class On client machine- clientApp.class, Interface.class, Server_stub.class.

7. Start RMI Registry RMI registry application is run as a background application on default port C:\> start rmiregistry [ ]

8. RUN RMI Application start rmiregistry java serverApp java clientApp

Removing Objects from registry Use java.rmi.Naming.unbind(URL)

Example Create airline.mdbairline.mdb Create a DSN “airline” javac AirlineInterface.javaAirlineInterface.java javac AirlineServer.javaAirlineServer rmic AirlineServer javac AirlineClient.javaAirlineClient.java On server start rmiregistry On server java AirlineServer On Client java AirlineClient