Introduction to Remote Method Invocation (RMI)

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

COS 461 Fall 1997 Network Objects u first good implementation: DEC SRC Network Objects for Modula-3 u recent implementation: Java RMI (Remote Method Invocation)
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.
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.
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.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
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.
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.
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.
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.
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.
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.
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.
Presentation 11: RMI introduction. Ingeniørhøjskolen i Århus Slide 2 af 20 Goals of this lesson After these 2x35 lessons you will be –Introduced to Java.
 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.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
Khoa CNTT 1/37 PHẠM VĂN TÍNH   Java RMI (Remote Method Invocation)
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.
Java Distributed Computing
Java Distributed Computing
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Java RMI (more) CS-328 Internet Programming.
Network and Distributed Programming in Java
Creating a Distributed System with RMI
Creating a Distributed System with RMI
Overview of RMI Architecture
Remote Method Invocation
Creating a Distributed System with RMI
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
Overview of RMI Architecture
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Introduction to Remote Method Invocation (RMI) Organizational Communications and Technologies Prithvi N. Rao H. John Heinz III School of Public Policy and Management Carnegie Mellon University

Posting on the Class Web Site Readings Posting on the Class Web Site

Objectives Present the basic features of RMI Present a simple piece of code implementing RMI

Overview of Network Programming Traditionally network programming has been difficult Need to implement a communications protocol in the application Need to understand machine specific dependencies RPC handles some of this complexity Port mapping is one example RPC permits programmer to concentrate on design more than implementation

Network Support in Java Support for TCP and UDP sockets is provided Developer still needs to worry about the packing and unpacking of data RPC falls short with object oriented code because there is no simple way to represent objects Methods take objects as parameters Return values are often objects RMI uses object serialization to accomplish sending objects as parameters and objects as return values

Basic Network Support in Java Serialization permits sending primitive types as objects String, Float Reference types Can reconstruct primitive type from object

The RMI Architecture RMI is java’s answer to RPC Also true for CORBA and DCOM RMI can be deployed on virtual machines on the same platform or across a network RMI provides a high level interface for building applications Aim is to facilitate the development of distributed applications as easily as non-distributed applications

The RMI Architecture User must locate objects User must know how to handle exceptions related to network communications No IDL as in CORBA and DCOM

The RMI Architecture Differences exist between local object and remote object invocation Object passed as a parameter in remote case must be serializable or another Remote object. Objects passed as parameters or values returned from methods must be passed by value not reference. Client always refers to remote object via one of the remote interfaces it implements.

Remote Object Structure Remote Method Invocation is made through reference to a remote object. Object is exported via a server application Handle to object is obtained by remote client Looks up registry Checking return value from another remote method call Object must implement at least one interface that extends the java.rmi.Remote interface

Remote Object Structure Reference to object is not sent over network to client requesting it Client uses a proxy for the object All interaction is done via proxy Each client has a stub for the remote object but there is only one remote object Can have many clients each with their stubs

Remote Object Structure Server has skeleton class Hands off the method calls and data to object being referenced

Remote Object Structure Client Server Stub Skeleton Remote Reference Layer Transport Layer

Remote Object Structure Layer1 is the application layer Actual implementation of the client and server applications High level calls are made to access and export remote objects

Remote Object Structure Layer 2 is the proxy layer or stub/skeleton layer Applications deal with this layer directly All calls to remote methods and marshalling of parameters and return objects done using proxies

Remote Object Structure Layer 3 is remote reference layer Deals with the semantics of remote invocation Responsible for handling replicated objects

Remote Object Structure Layer 4 is transport layer Sets up connection between client and server Handles transport from one machine to another

Application Layer Application must implement a remote interface Extend java.rmi.Remote Implementing interface is the same as any other java interface Additional network based exception handling code Export the object before use Extend the UnicastRemoteObject class

Application Layer Register application with a name server or registry Name service is only necessary at startup Client requests remote object from either a registry or remote object already obtained

The Stub Class Generated using the rmic compiler Stub is client side proxy for remote object Responsible for initiating call to remote object Stub responsible for marshaling method arguments

The Skeleton Class Also responsible for marshaling parameters Skeleton is on the server side Receives method calls from the client stubs Dispatches method calls to the server remote interface implementation

Remote Reference Layer Abstraction between stub and skeleton classes Handles replicated objects Replicated objects allow simple dispatch to many programs exporting the same interface Establishes persistence semantics and strategies for recovery of lost connections

Transport Layer Handles machine-to-machine communication Default communication is done via TCP/IP Can be modified to handle encrypted streams, compression algorithms and security and other performance related enhancements Application layers void of this detail

An Example In the server first extend the java.rmi.Remote interface import java.rmi.*; public interface Hello extends Remote { public String myHello() throws java.rmi.RemoteException }

An Example Define a class that implements the remote interface. This class extends java.rmi.UnicastRemoteObject import java.rmi.*; import java.rmi.server.*; import java.net.*; public class HelloImpl extends UnicastRemoteObject implements Hello { Public HelloImpl() throws RemoteException { return “Hello World!”; } ….continued in the next slide

An Example public static void main(String args[]) { try { HelloImpl h = new HelloImpl(); Naming.rebind(“hello”, h); System.out.println(“Server is ready”); } catch (RemoteException ex) { System.out.println(“Exception in HelloImpl.main” + ex); } catch(MalformedURLException ex) { System.out.println(“MalformedURLException in HelloImpl.main” + ex); }

An Example rmic HelloImpl Result is Hello.class Hello.java HelloImpl.class HelloImpl.java HelloImpl_Skel.class HelloImpl_Stub.class

An Example Start the registry rmiregistry 2048 & ( in unix) start rmiregistry 2048 (in dos) Now launch server java HelloImpl

An Example: Client Side import java.rmi.*; public class HelloClient { public static void main(String args[]) { System.setSecurityManager(new RMISecurityManager()); try { Hello h = (Hello) Naming.lookup(“hello”); String message = h.myHello(); System.out.println(“HelloClient: “ + message); } catch (Exception ex) { System.out.println(“Exception in main: “ + ex);

Summary RMI is alternative to CORBA and DCOM Aim is to make writing distributed java applications as simple as non distributed java applications Use of registry to register server Use of stubs and skeletons