Creating a Distributed System with RMI

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.
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.
5/15/2015B.Ramamurthy1 Creating a Distributed System with RMI B.Ramamurthy.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
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.
6/13/2015B.Ramamurthy1 System Models Bina Ramamurthy (Based on Slides from CDK text)
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
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,
Internet Software Development Remote Method Invocation Paul Krause.
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
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.
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.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
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.
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.
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.
6/5/2016B.Ramamurthy1 Distributed Objects and Remote Invocation Chapter 5 B.Ramamurthy.
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.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Remote Method Invocation Internet Computing Workshop Lecture 17.
Java Distributed Computing
Chapter 4 Remote Method Invocation
Java Distributed Computing
Java Remote Method Invocation (RMI)
Remote Method Invocation
Java RMI CS-328 Internet Programming.
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
Remote method invocation (RMI)
Creating a Distributed System with Remote Procedure Calls and Web Services Ch.5 B.Ramamurthy 2/17/2019 B.Ramamurthy.
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
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Creating a Distributed System with RMI B.Ramamurthy 1/18/2019 B.Ramamurthy

Remote Method Invocation Remote Method Invocation (RMI) is Java’s implementation of object-to-object communication among Java objects to realize a distributed computing model. RMI allows us to distribute our objects on various machines, and invoke methods on the objects located on remote sites. Source code for the demo is a modified version of code in Chapter 20 of Deitel & Deitel’s text Java : How to Program. 1/18/2019 B.Ramamurthy

RMI-based Distributed System 4. XYZ Implementation Client Host Server Host Client Stub interface uses implements 1. 2. 3. 5. 1/18/2019 B.Ramamurthy

Steps in RMI-based Application 1. Design the interface for the service. 2. Implement the methods specified in the interface. 3. Generate the stub and the skeleton. 4. Register the service by name and location. 5. Use the service in an application. 1/18/2019 B.Ramamurthy

Compile and Register Commands rmiregistry Finds object by name Stores object by name rmic 5. 3. 3. 2. XYZ Client Skeleton XYZ Implementation Stub 1. uses implements XYZ interface Client Host Server Host 1/18/2019 B.Ramamurthy

More Details Once the object (or service) is registered, a client can look up that service. A client (application) receives a reference that allows the client to use the service (call the method). Syntax of calling is identical to a call to a method of another object in the same program. 1/18/2019 B.Ramamurthy

Parameter Marshalling Transfer of parameters (or marshalling) is done by the RMI. Complex objects are streamed using Serialization. RMI model of networking for distributed system involves only Java. No need to learn IDL or any other language. 1/18/2019 B.Ramamurthy

Case Study : Temperature Service Lets create a distributed system using RMI model for networking (remote access). Basically this program will download the weather (temperature) information from the site: http://iwin.nws.noaa.gov/iwin/us/traveler.html 1/18/2019 B.Ramamurthy

Temperature Client/Server Distributed Application 4 rmic compiles 5. 3. generates 3. 2. TempClient TempImpl_Stub uses TempImpl_Stub TempServerImpl 1. uses implements TempServer Client Host Server Host 1/18/2019 B.Ramamurthy

Defining Remote Interface import java.rmi.*; // the interface extends Remote interface // any class implementing Remote can be accessed remotely security permitting public interface TemperatureServer extends Remote { // specify methods that can be called remotely // each method “throws RemoteException” } 1/18/2019 B.Ramamurthy

RemoteException Any time you depend on outside entities there is a potential for problems in communication, networking, server crash etc. Any exception due to these should be handled by the services. This feature imparts robustness to the application. Java mandates this feature for any RMI service. 1/18/2019 B.Ramamurthy

Implementing the Remote Interface import java.rmi.*; import java.rmi.server.*; import java.net.*; // others as needed TemperatureServerImpl extends UnicastRemoteObject implements TemperatureServer { 1/18/2019 B.Ramamurthy

TemperatureServerImpl This class’s constructor calls a private method which in turn: 1. Connects to the url specified 2. Streams into a buffer the page referenced. 3. Parses the buffer to get the required data. 4. Creates an array of weather information. 1/18/2019 B.Ramamurthy

TemperatureServerImpl (contd.) It implements the service method getWeatherInfo which simply returns the weather data gathered. The main method instantiates an object for the service, and registers it with rmiregistry. 1/18/2019 B.Ramamurthy

Streaming URLs Using the openStream of java.net.URL class you can stream in the file spefied by an universal resource locator(url). It can be streamed into a buffer where it can be analyzed for information. Any number of urls can be streamed in. Unicast Communication : When you are interested in a particular remote site you will direct your net connection to that particular site using unicast. 1/18/2019 B.Ramamurthy

Server Object Name Syntax for the server object name is: //host:port/remoteObjectName Default port number for rmiregistry is 1099 For local host the object name: //localhost/TempServer For a remote host //127.0.0.1/TempServer 1/18/2019 B.Ramamurthy

Name Binding rebind method binds a server’s object name to the object’s name as it is in the registry. Clients use the name in the registry. There is also a bind() method. But rebind is better since it binds the most recently registered object. 1/18/2019 B.Ramamurthy

WeatherInfo class It is very traditional class for keeping the information about the temperature at a single location. It has data fields : cityName, temperature, and description and get methods for these. An array of objects of this class is used in the server implementation. 1/18/2019 B.Ramamurthy

Temperature Client import java.rmi.*; // import other packages constructor calls a private method getRemoteTemp which takes care of lookup of remote object and access. In this application it also displays the information. 1/18/2019 B.Ramamurthy

Temperature Client (contd.) The main method in this client can get the IP address of the remote host as a command line argument. Command line argument is an array of String of items in the command line after the name of the application. 1/18/2019 B.Ramamurthy

Client Details The name of the server object along with the IP of the remote location is used in Naming class’s lookup method to get an object reference. This object reference is then used for remote method calls. Observe that there is no difference between the local and remote call. WeatherItem class used in the Graphical display of the weather information. 1/18/2019 B.Ramamurthy

Preparing the Application 1. Compile all the class using javac. 2. Generate the stub and the skeleton: rmic -v1.2 TemperatureServerImpl 3. Then start the registry (this will be running as a daemon) rmiregistry & 1/18/2019 B.Ramamurthy

Preparing the Application 4. Run the server which will register with the RMI registry. Java TemperatureServerImpl & 5. Run the client. Java TemperatureClient & or java TemperatureClient {IPAddress} java TemperatureClient 192.168.0.150 1/18/2019 B.Ramamurthy

Summary We discussed the various models of distributes systems. Java RMI was used to illustrate the distributed system concepts. Temperature examples shown illustrates some of the distributed system model discussed and all the important RMI features. 1/18/2019 B.Ramamurthy