Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.

Slides:



Advertisements
Similar presentations
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
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.
Remote Method Invocation in Java Bennie Lewis EEL 6897.
Distributed Objects and Remote Invocation: RMI & CORBA Most concepts are drawn from Chapter 5 © Pearson Education Dr. Rajkumar Buyya and Xingchen Chu Grid.
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.
DISTRIBUTED FILE SYSTEM USING RMI
Java RMI. What is RMI? RMI is an RPC system for an object based language. Objects provide a natural granularity for the binding of functions. –RMI allows.
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
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 RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
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.
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.
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.
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.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
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.
RMI Example. Compilation: /home2/fccheng/temp/RMI2> javac MyObject.java /home2/fccheng/temp/RMI2> javac RemoteServer.java /home2/fccheng/temp/RMI2> javac.
Florida State UniversityCOP Advanced Unix Programming Remote Method Invocation /rmi/index.html.
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.
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.
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.
Chapter 4 Remote Method Invocation
Java Remote Method Invocation (RMI)
RMI Packages Overview java.rmi java.rmi.server java.rmi.registry
Broker in practice: Middleware
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
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:

Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007

Fall 2007cs4252 Agenda Communication ~ Middleware –Distributed Objects –Remote Method Invocation (RMI)

Fall 2007cs4253 Distributed Objects Common organization of a remote object with client-side proxy. The “proxy” can be thought of as the “client stub”. The “skeleton” can be thought of as the “server stub”.

Fall 2007cs4254 Distributed Objects Remote Objects –Implement Interface  Proxy & Skeleton deal with marshalling and unmarshalling of parameters and messages –System wide State of the remote object is not distributed Persistent and Transient Objects –Existence w.r.t server process’s lifetime Location server & implementation handle

Fall 2007cs4255 Parameter Passing The situation when passing an object by reference or by value.

Fall 2007cs4256 Java RMI

Fall 2007cs4257 Creating Server Applications using RMI 1.Create the Interface to the server 2.Create the Server 3.Create the Client 4.Compile the Interface (javac) 5.Compile the Server (javac) 6.Compile the Client (javac) 7.Generate Stubs and Skeletons (rmic) 8.Start the RMI registry (rmiregistry) 9.Start the RMI Server 10.Start the RMI Client

Fall 2007cs4258 Example We will build a program (client) that access to a remote object which resides on a server. The remote object that we shall implement has a very simple functionality: return the current time in milliseconds since 1 January1970.

Fall 2007cs4259 Interface code import java.rmi.*; public interface Second extends Remote { long getMilliSeconds() throws RemoteException; } All the remote interfaces extend Remote ( java.rmi ). Objects created using this interface will have facilities that enable it to have remote messages sent to it. The interface must be declared public in order that clients can access objects which have been developed by implementing it. All methods that are called remotely must throw the exception RemoteException.

Fall 2007cs42510 Remote Object import java.rmi.*; import java.util.Date; import java.rmi.server.UnicastRemoteObject; public class SecondImpl extends UnicastRemoteObject implements Second { public SecondImpl() throws RemoteException {} public long getMilliSeconds() throws RemoteException { return(new Date().getTime()); //The method getTime returns the time in msecs }; }

Fall 2007cs42511 Explanation public class SecondImpl extends UnicastRemoteObject implements Second The class SecondImpl implements the remote interface Second and provides a remote object. It extends another class known as UnicastRemoteObject which implements a remote access protocol. NOTE: using UnicastRemoteObject enables us not to worry about access protocols.

Fall 2007cs42512 Explanation public SecondImpl(String objName) throws RemoteException { } This constructor calls the superclass constructor, of the UnicastRemoteObject class. During construction, a UnicastRemoteObject is exported, meaning that it is available to accept incoming requests by listening for incoming calls from clients on an anonymous port.

Fall 2007cs42513 Explanation public long getMilliSeconds() throws RemoteException { return(new Date().getTime()); //The method getTime returns the time in msecs } This method is the implementation of the getMilliSeconds method found in the interface Second. This just returns the time in milliseconds. NOTE: Again since it is a method which can be invoked remotely it could throw a RemoteException object.

Fall 2007cs42514 Server Code import java.rmi.naming; public class server { // RMISecurityManager sManager = new RMISecurityManager(); // System.setSecurityManager(sManager); public static void main(string[] args) { try { secondimpl remote = new secondimpl(); naming.rebind ("dater", remote); system.out.println("object bound to name"); } catch(exception e) { system.out.println("error occurred at server "+e.getmessage()); }

Fall 2007cs42515 Explanation Loads a security manager for the remote object. If this is not done then RMI will not download code (we discuss this later). import java.rmi.naming; public class server { // RMISecurityManager sManager = new RMISecurityManager(); // System.setSecurityManager(sManager); public static void main(string[] args) { try { secondimpl remote = new secondimpl(); naming.rebind ("dater", remote); system.out.println("object bound to name"); } catch(exception e) { system.out.println("error occurred at server "+e.getmessage()); }

Fall 2007cs42516 Explanation Creates an object import java.rmi.naming; public class server { // RMISecurityManager sManager = new RMISecurityManager(); // System.setSecurityManager(sManager); public static void main(string[] args) { try { secondimpl remote = new secondimpl(); naming.rebind ("dater", remote); system.out.println("object bound to name"); } catch(exception e) { system.out.println("error occurred at server "+e.getmessage()); }

Fall 2007cs42517 Explanation Informs the RMI naming service that the object that has been created (remote) is given the string name “dater”. import java.rmi.naming; public class server { // RMISecurityManager sManager = new RMISecurityManager(); // System.setSecurityManager(sManager); public static void main(string[] args) { try { secondimpl remote = new secondimpl(); naming.rebind ("dater", remote); system.out.println("object bound to name"); } catch(exception e) { system.out.println("error occurred at server "+e.getmessage()); }

Fall 2007cs42518 Essential Steps Declare the remote interface being implemented Define the constructor for the remote object Provide implementation for the remote methods in the remote interface Create and install a security manager Create an (more) instance of a remote object Register the remote object(s) with the RMI registry

Fall 2007cs42519 Client Code import java.rmi.*; public class TimeClient { public static void main(String[] args) { try { //RMISecurityManager sManager = new RMISecurityManager(); //System.setSecurityManager(sManager); Second sgen = (Second) Naming.lookup("rmi://localhost/Dater"); System.out.println("Milliseconds are "+sgen.getMilliSeconds()); } catch(Exception e) { System.out.println("Problem encountered accessing remote object "+e); }

Fall 2007cs42520 Explanation Looks up the object within the naming service which is running on the server using the static method lookup. The method lookup obtains a reference to the object identified by the string "Dater" which is resident on the server that is identified by "hostname"; public static void main(String[] args) { try { Second sgen = (Second) Naming.lookup("rmi://hostname/Dater"); System.out.println("Milliseconds are "+sgen.getMilliSeconds()); } catch(Exception e) { System.out.println("Problem encountered accessing remote object "+e); }

Fall 2007cs42521 Explanation Method is invoked public static void main(String[] args) { try { Second sgen = (Second) Naming.lookup("rmi://hostname/Dater"); System.out.println("Milliseconds are "+sgen.getMilliSeconds()); } catch(Exception e) { System.out.println("Problem encountered accessing remote object "+e); }

Fall 2007cs42522 Essential Steps Create and install the security manager (omitted in our example) Construct the name of the remote object Use the naming.lookup method to look up the remote object with name defined in the previous step Invoke the remote method on the remote object

Fall 2007cs42523 How will this work? Unanswered questions: –How about stub/skeletons? –And who provides the naming service? stub/skeletons are created by a RMI compiler –e.g. >rmic SecondImp creates –SecondImp_Skel.class –SecondImp_Stub.class The naming service implemented by the RMI registry is started on the server by rmiregistry

Fall 2007cs42524 Security Manager The JDK 1.2 onwards security model is more sophisticated than the model used for JDK 1.1. JDK 1.2 onwards releases contains enhancements for finer-grained security and requires code to be granted specific permissions to be allowed to perform certain operations. You need to specify a policy file

Fall 2007cs42525 Sample Policy The following policy allows downloaded code, from any code base, to do two things: –Connect to or accept connections on unprivileged ports (ports greater than 1024) on any host –Connect to port 80 (the port for HTTP) grant { permission java.net.SocketPermission "*: ","connect,accept"; permission java.net.SocketPermission "*:80", "connect"; };

Fall 2007cs42526 Summary Compile the interface, Server, and Client –> javac Second.java –> javac SecondImpl.java –> javac TimeClient.java Generate Stub and Skeleton –> rmic SecondImpl Start the rmiregistry –> rmiregistry Start the server –> java –Djava.security.policy = java.policy SecondImpl Start the client –> java -Djava.security.policy = java.policy TimeClient

Fall 2007cs42527 Parameter Passing Only primitive types and reference types that implement the Serializable interface can be used as parameter/return value types for remote methods.

Fall 2007cs42528 TimeTeller.java import java.util.Date; public class TimeTeller implements java.io.Serializable { public long getMilliSeconds() { System.out.println("TimeTeller"); return(new Date().getTime()); //The method getTime returns the time in msecs }

Fall 2007cs42529 New SecondImpl.java import java.util.Date; import java.rmi.*; import java.rmi.server.UnicastRemoteObject; public class SecondImpl extends UnicastRemoteObject Implements Second { … public TimeTeller getTimeTeller() throws RemoteException{ return new TimeTeller(); }

Fall 2007cs42530 New TimeClient.java import java.rmi.*; public class TimeClient { public static void main(String[] args) { try { Second sgen = (Second) Naming.lookup("rmi://localhost/Dater"); System.out.println("Server Milliseconds are "+sgen.getMilliSeconds()); TimeTeller tt = sgen.getTimeTeller(); System.out.println("Local Milliseconds are " + tt.getMilliSeconds()); } catch(Exception e) { System.out.println("Problem encountered accessing remote object "+e); }

Fall 2007cs42531 Questions? That’s all for today!