RMI Example. Compilation: /home2/fccheng/temp/RMI2> javac MyObject.java /home2/fccheng/temp/RMI2> javac RemoteServer.java /home2/fccheng/temp/RMI2> javac.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
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 Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
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
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
Introduction to Remote Method Invocation (RMI)
Algorithm Programming Distributed Programming in Java Bar-Ilan University תשס " ו by Moshe Fresko.
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 Computing 6. RMI By Dr. Jiang B. Liu
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.
CS603 Communication Mechanisms: DCE RPC (cont.) 23 January 2002.
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.
ICS 123 Java RMI ICS 123 Richard N. Taylor and Eric M. Dashofy* UC Irvine * with the usual thanks to David Rosenblum.
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.
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.
Presentation 18: RMI introduction. Goals of this lesson After this 35 min. lesson you will be: Introduced to Java RMI Ready to present RMI’s position.
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.
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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved TDTS04 Föreläsning.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
Vakgroep Informatietechnologie - IBCN CORBA & RMI Design of Distributed Software.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Example: RMI Program How to write it.
 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.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
RMI Observing the Distributed Pattern. Adrian German Lecturer, Computer Science Indiana University Bloomington.
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.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
Presentation: RMI Continued 2 Using The Registry & Callbacks.
 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.
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.
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.
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 Remote Method Invocation (RMI)
Remote Method Invocation
Remote Method Invokation
Remote Method Invocation
Advanced Remote Method Invocations
Java RMI (more) CS-328 Internet Programming.
Network and Distributed Programming in Java
5. Remote Method Invocation (RMI) 5. 1
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:

RMI Example

Compilation: /home2/fccheng/temp/RMI2> javac MyObject.java /home2/fccheng/temp/RMI2> javac RemoteServer.java /home2/fccheng/temp/RMI2> javac RemoteInterface.java /home2/fccheng/temp/RMI2> javac RemoteClient1.java /home2/fccheng/temp/RMI2> javac RemoteClient2.java

rmic RemoteServer -rw-r--r-- 1 fccheng staff 1712 May 12 17:40 RemoteServer_Skel.class -rw-r--r-- 1 fccheng staff 3223 May 12 17:40 RemoteServer_Stub.class

Java policy for RMI grant { permission java.net.SocketPermission "*: ", "connect,accept"; permission java.net.SocketPermission "*:80","connect"; };

start rmiregistry $ rmiregistery 1111 & Default TCP port: 1099

Run Server Run server program: (see RunServer script) java -Djava.rmi.server.codebase= temp/RMI2/ -Djava.rmi.server.hostname= Djava.security.policy=java.policy RemoteServer IP TCP-port

Run Clients Run client program: (see RunClient1 and RunClient2) java -Djava.rmi.server.codebase= temp/RMI2/ -Djava.security.policy=java.policy RemoteClient1 ServerIP:TCP-Port

Running Example Host Information: Host IP JDK OS App. ====== ============ ======== ===== ============== alpha: JDK Sol2.5 (client only) gamma: JDK 1.2 Sol2.6 (client and server) aimm: JDK 1.2 Sol2.6 (client and server) ====== ============ ======== ===== ==============

Snapshot:Client site aimm ***************************************************** aimm:/export/home/cheng/temp/RMI2> RunClient :1112 Running Client... Sending MyObject to Server... The server says : Total Message: 1 Client 1 aimm:/export/home/cheng/temp/RMI2> RunClient :1112 Running Client... Sending MyObject to Server... The server says : Total Message: 2 Client 1 2nd Client aimm:/export/home/cheng/temp/RMI2> *****************************************************

Snapshot:Client site alpha ***************************************************** alpha:/home2/cheng/temp/RMI2> java RemoteClient :1112 Running Client... Sending MyObject to Server... The server says : Total Message: 3 Client 1 2nd Client Client 1 alpha:/home2/cheng/temp/RMI2> *****************************************************

Snapshot: Server gamma ***************************************************** gamma:/home2/fccheng/temp/RMI2> RunServer Running Server... Server:rebining... Server got[8]:Client 1 Server got[10]:2nd Client Server got[8]:Client 1 *****************************************************

/* MyObject.java */ public class MyObject implements java.io.Serializable { private int x; private String msg; public MyObject (String s) { msg = s; x = msg.length(); } public int lenMsg() { return x; } public String getMsg() { return msg; } public void setMsg(String s) { msg = s; }

/* RemoteClient1.java */ import java.rmi.*; public class RemoteClient1 { public static void main(String args[]) { System.out.println("Running Client..."); System.setSecurityManager(new RMISecurityManager()); try { RemoteInterface server = (RemoteInterface) Naming.lookup("rmi://"+args[0] + "/"+"ObjectServerTest"); MyObject msgObj = new MyObject("Client 1"); System.out.println("Sending MyObject to Server..."); MyObject retObj = server.msgsend(msgObj); System.out.println("The server says :\n" + retObj.retMsg()); } catch (Exception e){ System.out.println("Error while performing RMI"); }

/* RemoteClient2.java */ import java.rmi.*; public class RemoteClient2 { public static void main(String args[]) { System.out.println("Running Client..."); System.setSecurityManager(new RMISecurityManager()); try { RemoteInterface server = (RemoteInterface) Naming.lookup("rmi://"+args[0] + "/"+"ObjectServerTest"); MyObject msgObj = new MyObject(”2nd Client"); System.out.println("Sending MyObject to Server..."); MyObject retObj = server.msgsend(msgObj); System.out.println("The server says :\n" + retObj.retMsg()); } catch (Exception e){ System.out.println("Error while performing RMI"); }

/* RemoteInterface.java */ public interface RemoteInterface extends java.rmi.Remote { MyObject msgsend (MyObject message) throws java.rmi.RemoteException; }

/* RemoteServer.java */ import java.rmi.*; import java.rmi.server.UnicastRemoteObject; public class RemoteServer extends UnicastRemoteObject implements RemoteInterface{ String name; static int messageCount; static String globalMessage=""; public RemoteServer(String name) throws RemoteException{ super(); this.name = name; }

public MyObject msgsend(MyObject message) throws RemoteException{ System.out.println("Server got[" + message.lenMsg() + "]:" + message.getMsg()); messageCount++; globalMessage=globalMessage+"\n"+message.getMsg(); message.setMsg("Total Message: "+ Integer.toString(messageCount)+globalMessage); return message; }

public static void main (String args[]){ System.out.println("Running Server..."); System.setSecurityManager (new RMISecurityManager()); try{ String myName = "//"+args[0]+":"+args[1]+ "/ObjectServerTest"; RemoteServer theServer = new RemoteServer (myName); System.out.println("Server:rebining..."); Naming.rebind(myName,theServer); } catch (Exception e){ System.out.println("An Exception occurred while creating server"); e.printStackTrace(); }