Remote Method Invocation Internet Computing Workshop Lecture 17.

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.
Remote Method Invocation (RMI) Mixing RMI and sockets
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.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
What iS RMI? Remote Method Invocation. It is an approach where a method on a remote machine invokes another method on another machine to perform some computation.
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.
DISTRIBUTED FILE SYSTEM USING RMI
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
Comparison of the RMI and the socket APIs
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)
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
Integration case study Week 8 – Lecture 1. Enrolment request (Workstation) Application server Database server Database New University Student Record System.
Internet Software Development Remote Method Invocation Paul Krause.
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets Rethinking out tic-tac-toe game.
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)
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
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.
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.
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.
 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.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
 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.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
Java Distributed Computing
Distributed Computing
Java Distributed Computing
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
Java RMI CS-328 Internet Programming.
What is RMI? Remote Method Invocation
Remote Method Invocation
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets
Knowledge Byte In this section, you will learn about:
Network and Distributed Programming in Java
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Creating a Distributed System with RMI
Chapter 40 Remote Method Invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
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:

Remote Method Invocation Internet Computing Workshop Lecture 17

Remote Method Invocation ● So far we have look at sending messages across a network. ● Remote Method Invocation (RMI) gives you access to objects that are implemented at a remote location. ● It's distributed programming in a fully object- oriented Java style.

Advantages of RMI ● You can program in a purely object-orientated style. ● Once it's set up you don't need to worry about handling remote access. ● No need to design a protocol for your system. ●

Disadvantages of RMI ● Needs additional configurations: ● Object registry ● Complied with rmic ● Hard to tell which objects are local and which are remote.

Remote Objects ● In RMI the client has access to an object that is implemented remotely. ● Fields of the object are stored remotely ● Remote data storage. ● Methods of the object are executed remotely ● Remote processing.

Communication Model ● With sockets: client and server communicate directly, exchanging messages. ● With RMI, a Registry lists all objects offered by the server. ● The server binds objects that the client can use. Server Client Registry Bind Object X X X?

Communication Model ● The client asks the registry for the object. ● This connects the object X to a stub. ● The client use the stub as if it was the object. Server Client Registry Bind Object X Give me X X Stub for X X?

Communication Model ● The client treats the stub like the real object. ● All methods called on the stub are forward to the server. ● The result is then returned to the client. Server Client Registry X Stub Method call Resul t

The Registry ● You must start the a registry running. ● e.g. type “ rmiregistry ” from the command line ● ● Usually runs on port 1099, but can run on any port and even on the same machine as the server. ● Interact with registry using the java.rmi.Naming class

Interface for the Object ● Both the client and the server must have access to an interface for the remote object. ● This interface must extend the java.rmi.Remote class. ● The methods may throw java.rmi.RemoteException

java.rmi.Naming bind(String name, Remote obj) – Adds the object “obj” to the registry under the name “name”. lookup (String name) – Returns a stub for the object called “name” unbind(String name) – Removes the object “name” from the registry list(String name) – Returns a list of all objects in the registry rebind (String name, Remote obj) – = unbind(name);bind(name,obj)

Registry URLs ● Services in registries can be addressed directly using a URL of the form: ● rmi:// [: ]/ rmi://localhost/printObject or rmi:// :30099/process These are used with the Naming.lookup method: Naming.lookup(rmi:// :30099/process) which returns the remote object called “process”

java.rmi.registry.LocateRegistry ● You can also refer to a Registry my creating a Registry object using the LocateRegistry package. ● LocateRegistry.getRegistry(h,p) return an reference to the registry runing on host h and on port p ● Registry registry = LocateRegistry.getRegistry(host); Ro o = (Ro)registry.lookup("service"); ● Is the same as: ● Ro o = (Ro)Naming.lookup("rmi://host/serv");

Communication Model Registry Implement s Client Gets Objec t Generate using rmic Calc Interface Calc Inpl Calc stub Calc Client Calc Server Bind s Client uses Stub Stub forwards Calls to remote stub

Running Code Example See handout

Distributing the Code ● Both the client and the server need the interface class. ● Client does not need the implementation ● Client does need the stub, but can fetch this dynamically, using the java.rmi.server.codebase ● java Calc -Djava.rmi.server.codebase=URLofStub

Communication Model Registry Stub and impl communicate Calc Interface Calc Impl Calc stub Calc Client Calc Server binds object Calc Interface Clien t Public Host Calc stub Server places stub on public host Client gets object

Method Arguments and RMI ● To keep things easy you should sending primitive data types as arguments and return values. ● You can send Objects that are “serializable” ● Make your own object serializable by extending the java.io.serializable class. ● The remote object is a new object: a copy of the one you sent.

CORBA vs RMI ● Common Object Request Broker Architecture (CORBA) is like RMI but not just in Java. ● Only primitive data types can be passed in CORBA. ● CORBA is very useful when new Java code is combined with legacy systems.

CORBA vs RMI ● CORBA uses a “Object Request Broker” (ORB), rather than a rmi registory. ● Interfaces in CORBA are written in Interface Definition Language (IDL). ● You then generate the Java Interface using “ildj”.

CORBA vs RMI ● “ildj” generates all the files you need. ● Use the “org.omg.CORBA.*” to distribution and access the object. ● Use CORBA for inter-language working. ● Or for legacy Systems ● Otherwise use RMI.

Summary ● RMI gives you access to objects that are implemented at a remote location. ● It's distributed programming in a fully object- oriented Java style. ● It needs addition configurations (registry,rmic) ● Hard to tell which objects are local and which remote.

For More Information ● For more on RMI see: ● For more on CORBA see:

Next Week: ● Guest Lecture by Andrew Watson from the Object Management Group (OMG). ● The API and standards you have learn in this module are developed and maintained by computer professionals and academics. ● It's quite possible that you will be involved in developing some future standards. ● Andrew Watson will tell you how this is done.