JAVA RMI. Remote Method Invocation

Similar documents
CSci Introduction to Distributed Systems. Communication: RPC In Practice

Remote Method Invocation

Remote Objects and RMI

Written by: Dave Matuszek

CS 5523 Operating Systems: Remote Objects and RMI

RMI. Remote Method Invocation. 16-Dec-16

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

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

Distributed Systems. 5. Remote Method Invocation

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

Remote Method Invocation in Java

Remote Method Invocation R.M.I.

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

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

Distributed Computing

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

5.4. Events and notifications

RMI Case Study. A Typical RMI Application

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

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

Remote Method Invocation

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

Remote Procedure Call

COMP 6231: Distributed System Design

Concurrent Object-Oriented Programming

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

Distributed Systems COMP 212. Lecture 10 Othon Michail

Last Class: Network Overview. Today: Distributed Systems

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

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

Remote Method Invocation

Agent and Object Technology Lab Dipartimento di Ingegneria dell Informazione Università degli Studi di Parma. Distributed and Agent Systems RMI

Generic architecture

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

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

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

Distributed Objects SPL/ SPL 201 / 0 1

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

presentation DAD Distributed Applications Development Cristian Toma

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

Distributed Software Systems

RMI Example RMI. CmpE 473 Internet Programming RMI

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

Component-Based Software Engineering

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

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

Verteilte Systeme (Distributed Systems)

6 Distributed Object-Based Systems

Reflection/RMI 4/28/2009

Lab 2 : Java RMI. request sayhello() Hello interface remote object. local object. response "Hello world"

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

Communication Basics, RPC & RMI. CS403/534 Distributed Systems Erkay Savas Sabanci University

EAST WEST UNIVERSITY

RPC and RMI. 2501ICT Nathan

IBD Intergiciels et Bases de Données

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

Programming with RMI Reminder

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

DISTRIBUTED COMPUTING

Distributed object component middleware I - Java RMI

JAVA RMI Java, summer semester

Distributed Programming in Java. Distribution (2)

RMI. (Remote Method Invocation)

Distributed object component middleware I - Java RMI

Modulo II Socket, RMI e Corba

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

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

CSE 124 Distributed programming and Remote Procedure Calls (RPC) February 23, 2016, UCSD Prof. George Porter

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

Chapter 5 Distributed Objects and Remote Invocation

Remote Method Invocation Java RMI & Web-Services

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

Distributed Information Systems

Chapter 4 Remote Procedure Calls and Distributed Transactions

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

Lecture 15: Frameworks for Application-layer Communications

Lecture 15: Frameworks for Application-layer Communications

Communication and Distributed Processing

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

Lecture VI: Distributed Objects. Remote Method Invocation

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

IJESRT. http: //

Lecture 18 Inside Java RMI

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

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

Communication and Distributed Processing

Course Snapshot. The Next Few Classes

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

Remote Method Invocation. Benoît Garbinato

Remote Method Invocation Benoît Garbinato

Lecture 17 Java Remote Method Invoca/on

Chapter 4: Processes. Process Concept. Process State

Advanced Java Programming

5 Distributed Objects: The Java Approach

Java Remote Method Invocation Specification

Lecture 5: Object Interaction: RMI and RPC

CSS 533 Program 3: Mobile-Agent Execution Platform Professor: Munehiro Fukuda Due date: see the syllabus

Java Remote Method Invocation Specification

Distributed Systems Recitation 3. Tamim Jabban

BEA WebLogic. Server. Programming WebLogic RMI

Transcription:

1 JAVA RMI Remote Method Invocation

2 Overview Java RMI is a mechanism that allows one to invoke a method on an object that exists in another address space. The other address space could be: On the same machine On a different one. The RMI mechanism is basically an object-oriented RPC (Remote Procedure Call) mechanism.

The proxy can be thought of as the client stub. The skeleton can be thought of as the server stub 3

4 Stub & Skeleton A client invokes a remote method, the call is first forwarded to stub. The stub is responsible for sending the remote call over to the server-side skeleton The stub opening a socket to the remote server, marshaling the object parameters and forwarding the data stream to the skeleton. A skeleton contains a method that receives the remote calls, unmarshals the parameters, and invokes the actual remote object implementation.

5 RMI Components The Client is the process that is invoking a method on a remote object. The Server is the process that owns the remote object. The remote object is an ordinary object in the address space of the server process. The Object Registry is a name server that relates objects with names. Objects are registered with the Object Registry. Once an object has been registered, one can use the Object Registry to obtain access to a remote object using the name of the object.

A Remote class has two parts: the interface and the class itself. The Remote interface must have the following properties: The interface must be public. The interface must extend the interface java.rmi.remote Every method in the interface must declare that it throws java.rmi.remoteexception. Other exceptions may also be thrown. 6 Remote Classes and Interfaces

7 1. It must implement a Remote interface. 2. It should extend the java.rmi.server.unicastremoteobject class. Objects of such a class exist in the address space of the server and can be invoked remotely. 3. It can have methods that are not in its Remote interface. These can only be invoked locally. Properties of Remote classes

8 Client-Server Apps w RMI 1. Define the remote interface 2. Develop the remote object by implementing the remote interface. 3. Compile the Java source files. 4. Start the RMI registry. 5. Develop the Server program 6. Start the remote server objects. 7. Develop the client program. 8. Run the client

9 CREATE INTERFACE & REMOTE OBJECT CODE

10 Example: A Remote interface import java.rmi.*; public interface HelloInterface extends Remote { } // Remotely invocable method. // return the message of the remote object, // exception RemoteException public String say() throws RemoteException;

import java.rmi.*; import java.rmi.server.*; public class Hello extends UnicastRemoteObject implements HelloInterface { private String message; // Constructor public Hello (String msg) throws RemoteException { message = msg; } // implementation public String say() throws RemoteException { return message; } }

12 Compile, All of the Remote Generate interfaces Stub and & classes Skeleton should be compiled using javac. Once this has been completed, the stubs and skeletons for the Remote interfaces should be compiled by using the rmic stub compiler. The stub and skeleton of the example Remote interface are compiled with the command: rmic Hello

public static void main (String[] argv) { } try { // java.rmi.registry.locateregistry.createregistry(1099); Hello remote = new Hello( Hello, world! ); Naming.rebind ("Hello", remote); System.out.println ("Hello Server is ready."); } catch (Exception e) { System.out.println ("Hello Server failed: " + e); } The rmiregistry Object Registry only accepts requests to bind and unbind objects running on the same machine, so it is never necessary to specify the name of the machine when one is registering an object. Server program 13

14 Starting the server Before starting the Server, one should first start the Object Registry, and leave it running in the background rmiregistry The Server should then be started; and, like the Object Registry, left running in the background. The example Server is started using the command: java HelloServer

15 Key steps in RMI Client 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

public static void main (String[] argv) { try { HelloInterface hello = (HelloInterface) Naming.lookup ( rmi://ortles.ccs.neu.edu/hello"); System.out.println (hello.say()); } catch (Exception e) { } System.out.println ("HelloClient exception: " + e); } The Naming.lookup method obtains an object handle from the Object Registry running on ortles.ccs.neu.edu and listening to the default port. The result of Naming.lookup must be cast to the type of the Remote interface. Client program 16

17 Running a client The Client is executed using: java HelloClient