Component-Based Software Engineering

Similar documents
JAVA RMI. Remote Method Invocation

IJESRT. http: //

Remote Method Invocation in Java

RMI (Remote Method Invocation) Over the year, there have been 3 different approaches to application development:

5.4. Events and notifications

Desarrollo de Aplicaciones en Red RMI. Introduction. Considerations. Considerations. RMI architecture

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

Last Class: Network Overview. Today: Distributed Systems

presentation DAD Distributed Applications Development Cristian Toma

Remote Procedure Call

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

Distributed Systems. 02r. Java RMI Programming Tutorial. Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

Remote Method Invocation

Reflection/RMI 4/28/2009

Distributed Computing

Remote Method Invocation

Bharati Vidyapeeth s Institute of Computer Applications and Management A-4, Paschim Vihar, New Delhi-63.

Remote Method Invocation R.M.I.

Lecture 18 Inside Java RMI

JAC444 - Lecture 11. Remote Method Invocation Segment 2 - Develop RMI Application. Jordan Anastasiade Java Programming Language Course

Generic architecture

Distributed Software Systems

Applications. RMI, RPC and events. Request reply protocol External data representation. Operating System

RMI Case Study. A Typical RMI Application

JAVA RMI Java, summer semester

Distributed Systems. 5. Remote Method Invocation

The UNIVERSITY of EDINBURGH. SCHOOL of INFORMATICS. CS4/MSc. Distributed Systems. Björn Franke. Room 2414

Grid Computing. Java Remote Method Invocation (RMI) RMI Application. Grid Computing Fall 2006 Paul A. Farrell 9/5/2006

Remote Method Invocation

Written by: Dave Matuszek

Modulo II Socket, RMI e Corba

Distributed Systems COMP 212. Lecture 10 Othon Michail

CSci Introduction to Distributed Systems. Communication: RPC In Practice

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

RMI. Remote Method Invocation. 16-Dec-16

Distributed Programming in Java. Distribution (2)

Distributed Objects SPL/ SPL 201 / 0 1

Remote Objects and RMI

RMI Example RMI. CmpE 473 Internet Programming RMI

Department of Computer Science & Engineering. M.Tech(CSE)-I Year-II Semester WEB SERVICES AND SERVICE ORIENTED ARCHITECHTURE (B1513) Mr.K.

Distributed Programming with RMI. Overview CORBA DCOM. Prepared By: Shiba R. Tamrakar

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9,

CS 5523 Operating Systems: Remote Objects and RMI

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Course Snapshot. The Next Few Classes

COMP 6231: Distributed System Design

Distributed Applications Programming. Lab 4

Distributed object component middleware I - Java RMI

Distributed object component middleware I - Java RMI

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Course Snapshot. The Next Few Classes. Parallel versus Distributed Systems. Distributed Systems. We have covered all the fundamental OS components:

Programming with RMI Reminder

5 Distributed Objects: The Java Approach

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

RMI. (Remote Method Invocation)

CC755: Distributed and Parallel Systems

#,!" $* ( #+,$ $$ $# -.,$ / 0' ".12 $ $$ 5/ #$" " " $ $ " # $ / 4 * # 6/ 8$8 ' # 6 $! 6$$ #$ * $ $$ ** 4 # 6 # * 0; & *! # #! #(' 7 / $#$ -.

Verteilte Systeme (Distributed Systems)

Activation of remote objects

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

Java WebStart, Applets & RMI

Questions and Answers. A. RMI allows us to invoke a method of java object that executes on another machine.

Sockets and RMI. CS151 Chris Pollett Dec. 5, 2005.

Java RMI Activation: A running example We have the following classes: MyRemoteInterface: the remote interface. Client: the client that invokes a

Activation of remote objects

THE RMI PROXY USER GUIDE

Chapter 4 Remote Procedure Calls and Distributed Transactions

COMP 6231 Distributed Systems Design. Tutorial 2 by Alexandre Hudon January 21 st, 2013

Communication and Distributed Processing

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Lecture 17 Java Remote Method Invoca/on

Remote Method Invocation Java RMI & Web-Services

Lecture VI: Distributed Objects. Remote Method Invocation

Info 408 Distributed Applications programming 2 nd semester of Credits: 5 Lecturer: Antoun Yaacoub Ph.D.

Communication and Distributed Processing

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

IBD Intergiciels et Bases de Données

How are classes loaded into the Java Virtual Machine (JVM)? from the local file system (CLASSPATH). by an instance of ClassLoader

55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP)

Remote Method Invocation. Benoît Garbinato

Remote Method Invocation Benoît Garbinato

1 interface TemperatureSensor extends java.rmi.remote 2 { 3 public double gettemperature() throws java.rmi.remoteexception; 4 public void

Lecture 5: RMI etc. Servant. Java Remote Method Invocation Invocation Semantics Distributed Events CDK: Chapter 5 TVS: Section 8.3

CS193k, Stanford Handout #12. Threads 4 / RMI

Java Remote Method Invocation Specification

Distributed Applications Programming. Lab 7

Chapter 15: Distributed Communication. Sockets Remote Procedure Calls (RPCs) Remote Method Invocation (RMI) CORBA Object Registration

Outline. Chapter 4 Remote Procedure Calls and Distributed Transactions. Remote Procedure Call. Distributed Transaction Processing.

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1

RPC is a call to a procedure/function located on another machine

EAST WEST UNIVERSITY

Chapter 5 Distributed Objects and Remote Invocation

BEA WebLogic. Server. Programming WebLogic RMI

Developing RMI Based Server (ChatServer)

PART VII Building Web Services With JAX-RPC. 7.5 JAX Web Service Architecture. Development of a Web Service with JAX. Runtime View of a Web Service

Web. Remote Method Invocation. core. programming. Training Courses: Java, JSP, Servlets, Struts, & JSF:

EDA095 Remote Method Invocation

EDA095 Remote Method Invocation

Transcription:

Component-Based Software Engineering Remote Method Invocation Paul Krause Introduction to RMI Lecture 11 - RMI Simple Example - DivideServer Demo of this example Review a more complex example - StudentEnrollment 1

What is RMI? A high-level networking technology for distributed Java applications Allows a Java object executing on one machine to remotely invoke methods in an object executing on a second machine Such method calls have the appearance of operating on objects in the same program Skeletons and Stubs Client Machine Server Machine C Client S Server Stub Skeleton Java Virtual Machine and RMI System Java Virtual Machine and RMI System 2

Stub Presents same interfaces as remote object Works with JVM and RMI to serialise arguments in the remote method call Receives results from the remote method call and returns them to the client object Skeleton Receives the remote method call and associated arguments Works with JVM and RMI to deserialize arguments in the remote method call Invokes appropriate methods in the remote object Receives return value (if any) from the method call, serializes it and returns it to the client No longer needed in Java 2 3

Referencing remote objects A Registry object maintains a mapping from Server names to remote object references We will use the example DivideServer The remote object is named via a URL using the RMI protocol: rmi://host:port/server host - IP address or name of server machine port - optional port number of the Registry on above server - name of the remote server e.g. rmi://127.0.0.1/divideserver Key Classes and Interfaces Remote Interface Naming Class RemoteObject Class RemoteServer Class UnicastRemoteObject Class RemoteException Class 4

Remote Interface In the java.rmi package Contains no constants or methods It is used to designate which interfaces are remote - remote interfaces must extend java.rmi.remote remote objects must implement a remote interface Naming Class In the java.rmi package Three methods to associate names with remote objects (used at the Server side): static void bind(string name, Remote robj) static void rebind(string name, Remote robj) static void unbind(string name) One method to obtain a name for a remote object (used at the Client side): static Remote lookup(string url) 5

Remote Objects RemoteObject extends java.lang.object to provide correct behaviour for remote objects RemoteServer an abstract class that extends RemoteObject. Defines the methods needed to create and export remote objects UnicastRemoteObject a concrete subclass of RemoteServer. Extend this class to make a remote object Simple Client/Server Application Client program takes three arguments: IP address or name of remote server two numbers The two numbers are passed to the server The server divides one into the other and returns the result From: JavaBeans Programming from the Ground Up, Joseph O Neil and Herb Schildt 6

DivideServer.java import java.rmi.*; public interface DivideServer extends Remote { double divide(double d1, double d2) throws RemoteException; Remote Interfaces The remote interface must extend Remote Remote methods can throw a RemoteException We now require a server that implements the interface By convention, we name the implementation of DivideServer DivideServerImpl Remote objects must extend UnicastRemoteObject 7

DivideServerImpl.java import java.rmi.*; import java.rmi.server.*; public class DivideServerImpl extends UnicastRemoteObject implements DivideServer { public DivideServerImpl( ) throws RemoteException { public double divide(double d1, double d2) throws RemoteException { return d1/d2; DivideServerApp.java This is the main program for the server side Its primary function is to bind the name DivideServer to an instance of DivideServerImpl Note that we need to start this server program running before the client program is invoked 8

DivideServerApp.java Core part is: DivideServerImpl divideserverimpl; divideserverimpl = new DivideServerImpl(); Naming.rebind("DivideServer", divideserverimpl); DivideServerApp.java import java.net.*; import java.rmi.*; public class DivideServerApp { public static void main(string args[]) { try { DivideServerImpl divideserverimpl; divideserverimpl = new DivideServerImpl(); Naming.rebind("DivideServer", divideserverimpl); catch(exception ex) { ex.printstacktrace(); 9

DivideCleint.java Looks up the object that is bound to the RMI URL The lookup method of the Naming class returns an object of type Remote This must then be cast to a DivideServer in order to be able to access the divide method DivideCleint.java DivideServer divideserver; divideserver = (DivideServer)Naming.lookup(divideServerURL); // Invoke remote method and display results double result = divideserver.divide(d1, d2); System.out.println("The result is: " + result); 10

DivideCleint.java import java.rmi.*; public class DivideClient { public static void main(string args[]) { try { // Make rmi URL to name DivideServer String divideserverurl; divideserverurl = "rmi://" + args[0] + "/DivideServer"; // Obtain reference to that remote object DivideServer divideserver; divideserver = (DivideServer)Naming.lookup(divideServerURL); DivideCleint.java // Display numbers System.out.println("The first number is: " + args[1]); double d1 = Double.valueOf(args[1]).doubleValue(); System.out.println("The second number is: " + args[2]); double d2 = Double.valueOf(args[2]).doubleValue(); // Invoke remote method and display results double result = divideserver.divide(d1, d2); System.out.println("The result is: " + result); catch(exception ex) { ex.printstacktrace(); 11

Executing the Application Use javac to compile all files Open a command prompt and change to the working directory Use the rmic compiler to produce a stub class for the remote server class: rmic -v1.2 DivideServerImpl Copy all files to the client machine exercise: You don t need all of them on the client. Which ones do you need Executing the Application open a command prompt on the server and start the RMI registry: rmiregistry open a second command prompt on the server machine and run the server application to bind the remote server object to the registry java DivideApp Start the client (again, use a command prompt): java DivideClient server1 8 2 12

The result You should get the following output at the client s command prompt: The first number is: 8 The second number is: 2 The result is: 4.0 Notes: Use IP address 127.0.0.1 if experimenting on a single machine On Windows 2000 you can find out the IP address of a machine using hostname and ipconfig/all 13