1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*

Slides:



Advertisements
Similar presentations
CS Network Programming CS 3331 Fall CS 3331 Outline Socket programming Remote method invocation (RMI)
Advertisements

J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
Network Programming and Java Sockets
1 Applets Programming Enabling Application Delivery Via the Web.
Using RMI–IIOP in the Development of Distributed Applications Dr. P.G.Sarang, President & ABCOM Information Systems Private. Limited.,
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
1 Communication in Distributed Systems REKs adaptation of Tanenbaums Distributed Systems Chapter 2.
ABC Technology Project
1 public class Newton { public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t)
1 Review Quisioner Kendala: Kurang paham materi. Praktikum Pengaruh teman.
DISTRIBUTED OBJECTS AND REMOTE INVOCATION
Chapter 5 Loops Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
25 seconds left…...
Local vs. distributed Objects Differences between local and distributed objects in: –References (to objects) –Activation/Deactivation –Migration –Persistence.
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
We will resume in: 25 Minutes.
Remote Method Invocation (RMI) and Distributed Observers in Java
Remote method invocation. Introduction First introduced in JDK 1.1. Allows distributed Java programs to work with each others by behaving as if they are.
Chapter 8 Improving the User Interface
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.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
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.
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
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.
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.
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.
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 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.
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 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.
Changing the way of designing distributed applications Communication oriented design: FIRST design the communication protocol for the distributed system.
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.
1 RMI Russell Johnston Communications II. 2 What is 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.
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.
January 26, Ann Wollrath Copyright 1999 Sun Microsystems, Inc., all rights reserved. Java ™ RMI Overview Ann Wollrath Senior Staff Engineer Sun Microsystems,
Java Distributed Computing
Java Remote Method Invocation (RMI)
Remote Method Invocation
CS 584 Lecture 18 Assignment Glenda assignment extended to the Java RMI Deadline No Java RMI Assignment Test Friday, Saturday, Monday.
Changing the way of designing distributed applications
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*

2 Local Procedure Calls #include int myFunc (stuff) int main ( ) { : val = myFunc(stuff) : } int myFunc(stuff) { : }

3 Local Procedure Call Limitations Function is bound to the executing program –compiled (or linked) into executable code If function is needed again, it is copied –Any function modifications must be made to all copies

4 Remove LP Limitations Remove the static relationship between function and calling program. –Allow function to be dynamically associated with calling program Windows dynamically linked library More general approach is to use Remote Procedure Calls –Developed in 1980’s

5 Remote Procedure Approach Allow function call to span processes or even machines. Replace (extend) the function call process. –Develop a standard set of rules (interface) that allows any process to call any function that follows the interface rules Automatically build interface files needed to connect caller to function –Method_Skel.class –Method_Stub.class

6 Remote Procedure Issues Where is the function? –Addressing procedures –Registration procedures How do we format the data? –Must be readable by all utilized platforms –Common definitions for data (integers, floats, etc.) –Common byte order –Common structure

7 Remote Method Invocation Java to Java approach for distributed communication and computation Establishes Method Registry Uses existing data management mechanisms to control data flow –Object serialization

8 RMI Benefits Supports Distributed processing –Function can be located anywhere... Supports Shared use of functions –All users use same function, get same responses Supports Dynamic implementation of function –Independent of calling program –Within limits (interface remains the same)

9 Serializing Data Needed when objects must be passed Serializable objects implement the serializable interface –java.io.serializable Most common objects implement serializable Custom objects may need to implement the serializable interface to allow then to be transported between client and server

10 Remote Method Process Define remote method (RM) Define interface between caller and RM Make data serializable Build remote method interface Build remote method (server) Build calling program (client) Compile server, client, and interface Start server, register service Run calling program (client)

11 RMI Example Implement Fahrenheit to centigrade temperature conversion using a remote method. Remote method takes a Fahrenheit temperature and returns the equivalent centigrade temperature.

12 Define Remote Method centigrade = 5*(Fahrenheit - 32) /9

13 Define Remote Interface Input: –temperature in Fahrenheit Return: –temperature in Celsius Specify both values as integers –computations are rounded –integers are serializable

14 Build RM Interface import java.rmi.*; public interface iTemp extends Remote { public int getTemp( int farTemp) throws RemoteException; }

15 Build Server import java.rmi.*; import java.rmi.registry.*; import java.rmi.server.*; public class TempConverter extends UnicastRemoteObject implements iTemp { public TempConverter() throws RemoteException {} public int getTemp( int farTemp) { return ((int)(5*(farTemp -32)/9)); }

16 Build Server public static void main(String args[]) { try { TempConverter tc = new TempConverter(); String servObjName = "///TempConverter"; Naming.rebind(servObjName, tc); System.err.println("TempConv is up!"); } catch (Exception e) { e.printStackTrace( ); } }//end of main }//end of TempConverter

17 Build Client import java.rmi.*; import java.io.*; public class TempUser { public static void main(String args[]) { DataInputStream dis = new DataInputStream (System.in); String sIn; int nuTemp; iTemp remoteTemp;

18 Build Client try { remoteTemp = (iTemp) Naming.lookup ("rmi://vudt-cotter.cstp.umkc.edu/TempConverter"); System.out.print("Enter temperature(Farenheit) "); System.out.flush(); sIn = dis.readLine(); nuTemp = remoteTemp.getTemp(Integer.parseInt(sIn)); System.out.println("That is "+ nuTemp + " degrees centigrade"); } catch (Exception e) { e.printStackTrace(); } } //end of main }// end of TempUser

19 Compile programs Compile Server –javac TempConverter.java Create Remote Method Stubs and clients –rmic TempConverter Compile Client –(uses TempConverter_Stub.class) –javac TempUser.java

20 Register Service / Run Program Start up RMI registry –rmiregistry Start up Server –java TempConverter Start up Client –java TempUser

21 RMI TempConverter Output Server Side... D:\data\cs423\java\tempRMI>start rmiregistry D:\data\cs423\java\tempRMI>java TempConverter TempConv is up! ^C D:\data\cs423\java\tempRMI> Client Side... D:\data\cs423\java\tempRMI>java TempUser Enter temperature(Farenheit) 32 That is 0 degrees centigrade D:\data\cs423\java\tempRMI>

22 iMath.java import java.rmi.*; java.io.*; public interface iMath extends Remote { public int getSum( Numbers sum) throws RemoteException; public int getProduct( Numbers product) throws RemoteException; public class Numbers implements Serializable { private int num1; private int num2; private int num3; public Numbers() { } public void setN1(int num) { num1 = num; } public void setN2(int num) { num2 = num; } etc.

23 MathServer.java import java.rmi.*;import java.rmi.registry.*;import java.rmi.server.*; public class MathServer extends UnicastRemoteObject implements iMath { public MathServer() throws RemoteException {} public int getSum( iMath.Numbers sum) { int n1, n2, n3; : return (nuSum); } public int getProduct( iMath.Numbers product) { int n1,n2, n3; : return (nuProd); }

24 MathServer.java public static void main(String args[]) { try { MathServer ms = new MathServer(); String servObjName = "///MathServer"; Naming.rebind(servObjName, ms); System.err.println("MathServer is up!"); } catch (Exception e){ e.printStackTrace(); }

25 MathUser.java import java.rmi.*; import java.io.*; public class MathUser { public static void main(String args[]) { BufferedReader dis= new BufferedReader(new InputStreamReader(System.in)); String sIn1, sIn2, sIn3; int add1, add2, add3,answer; iMath remoteAdder; iMath.Numbers nums = new iMath.Numbers(); try { remoteAdder = (iMath) Naming.lookup ("rmi:// /MathServer"); System.out.print("Enter First number (integers) "); System.out.flush(); sIn1 = dis.readLine(); System.out.print("Enter Second number (integers) "); System.out.flush(); sIn2 = dis.readLine();

26 MathUser.java System.out.print ("Enter Third number (integers) "); System.out.flush(); sIn3 = dis.readLine(); nums.setN1(Integer.parseInt(sIn1)); nums.setN2(Integer.parseInt(sIn2)); nums.setN3(Integer.parseInt(sIn3)); System.out.print("Do you want the Sum or Product (S or P)?"); sIn1 = dis.readLine(); if (sIn1.equals("S")) { answer = remoteAdder.getSum(nums); System.out.println("That sum is " + answer ); } else { answer = remoteAdder.getProduct(nums); System.out.println("That product is " + answer ); } } catch (Exception e) { e.printStackTrace(); } }

27 Summary Java RMI process similar to RPC RMI Registry acts as Portmapper. Registry is located on serving host. RMIC acts as remote method communications generator (RPCgen)