Chapter 4 Remote Method Invocation

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

COS 461 Fall 1997 Network Objects u first good implementation: DEC SRC Network Objects for Modula-3 u recent implementation: Java RMI (Remote Method Invocation)
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
Remote Method Invocation in Java Bennie Lewis EEL 6897.
Distributed Object & Remote Invocation Vidya Satyanarayanan.
5/15/2015B.Ramamurthy1 Creating a Distributed System with RMI B.Ramamurthy.
Remote Method Invocation
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.
Java RMI, JAX-RPC and JWSDP
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.
Internet Software Development Remote Method Invocation Paul Krause.
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
1 Java Programming II Java Network II (Distributed Objects in Java)
+ A Short Java RMI Tutorial Usman Saleem
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors.
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 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.
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.
Distributed objects and remote invocation Pages
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.
Distributed programming in Java Faculty:Nguyen Ngoc Tu Session 5 - RMI.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
6/5/2016B.Ramamurthy1 Distributed Objects and Remote Invocation Chapter 5 B.Ramamurthy.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Java Distributed Computing
Chapter 5 Remote Procedure Call
Java Distributed Computing
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
Programming Models for Distributed Application
DISTRIBUTED COMPUTING
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
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.
Overview of RMI Architecture
Remote Method Invocation
Distribution Infrastructures
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
Overview of RMI Architecture
Presentation transcript:

Chapter 4 Remote Method Invocation From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design

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. 4/25/2018

The role of proxy and skeleton (stub) in remote method invocation server client remote skeleton object B object A proxy for B Request & dispatcher for B’s class Reply servant Communication Communication Remote reference Remote module reference module module module Object A invokes a remote object in Object B for which it holds a remote object reference. 4/25/2018

RMI Internals: Client side stub The stub is an object that resides at the client side and represents the remote object. When the caller invokes method on the stub object, it does the following tasks: It initiates a connection with remote Virtual Machine (JVM), It writes and transmits (marshals) the parameters to the remote Virtual Machine (JVM), It waits for the result It reads (unmarshals) the return value or exception, and It finally, returns the value to the caller. 4/25/2018

RMI Internals: Server side stub/skeleton When the skeleton receives the incoming request, it does the following tasks: It reads the parameter for the remote method It invokes the method on the actual remote object, and It writes and transmits (marshals) the result to the caller. 4/25/2018

RMI Internals: Communication Module Carries out request-reply protocol; On the client side {message type, message id, remote reference to object} are gathered and sent out. At most once invocation semantics; On the server side, it gets local reference for remote reference from remote reference module, invokes a dispatcher with this reference. 4/25/2018

RMI Internals: Remote Reference module Responsible for translating between local and remote object references and for creating remote object references. A remote object table has a mapping between local and remote references. A table at server (entry for object ref for B) and a table at client (entry for object ref for proxy B). 4/25/2018

RMI-based Distributed System 4. rmiregistry Finds object by name Stores object by name rmic Compile 5. 3. 3. 2. XYZ Client Stub XYZ Implementation Stub 1. uses implements XYZ interface Client Host Server Host 4/25/2018

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. 4/25/2018

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. 4/25/2018

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. 4/25/2018

Define the remote interface Implement the server Implement the client Java RMI Define the remote interface Implement the server Implement the client Compile the source files Start the Java RMI registry, server, and client Take a look at: http://download.oracle.com/javase/6/docs/technotes/gu ides/rmi/hello/hello-world.html 4/25/2018

Defining Remote Interface Import java.rmi.*; The interface extends Remote interface Specify methods that can be called remotely Each method “throws RemoteException” 4/25/2018

Any exception due to these should be handled by the services. 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. 4/25/2018

Implementing the server import java.rmi.*; import java.rmi.server.*; import java.net.*; // others as needed XYZImpl implements TemperatureServer { The main method: (1) creates and exports an object for the service, and (2) registers it with rmiregistry. 4/25/2018

Create and export an object 4/25/2018

UnicastRemoteObject UnicastRemoteObject is a base for your remote object that provides simple transient point-point RMI servers. Exports the supplied remote object to receive incoming remote method invocations on an anonymous TCP port and returns the stub for the remote object to pass to clients. The returned stub implements the same set of remote interfaces as the remote object's class and contains the host name and port over which the remote object can be contacted. 4/25/2018

Register the remote object 4/25/2018

Java RMI Registry Java RMI provides a registry API for applications to bind a name to a remote object's stub and for clients to look up remote objects by name in order to obtain their stubs. A Java RMI registry is a simplified name service that allows clients to get a reference (a stub) to a remote object. Once a remote object is registered on the server, callers can look up the object by name, obtain a remote object reference, and then invoke remote methods on the object. 4/25/2018

Clients use the name in the registry. There is also a bind() method. 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. 4/25/2018

Syntax for the server object name is: rmi://host:port/remoteObjectname Default port number for rmiregistry is 1099 For local host the object name: rmi://localhost:1099/XYZServer For a remote host rmi://127.0.0.1:1099/XYZServer e.g., Serverside: registry.rebind("rmi://localhost:5000/hello",stub); Clientside: xxx stub=(xxx)registry.lookup("rmi://localhost:5000/hello");    4/25/2018

Implement the client 4/25/2018

This object reference is then used for remote method calls. 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. 4/25/2018

After invoke sayHello() The clientside runtime opens a connection to the server using the host and port information in the remote object's stub and then serializes the call data. The serverside runtime accepts the incoming call, dispatches the call to the remote object, and serializes the result (the reply string "Hello, world!") to the client. The clientside runtime receives, deserializes, and returns the result to the caller. 4/25/2018

Compile the source files Compile all the class using javac. e.g., javac d destDir Hello.java Server.java Client.java Note: If the server needs to support clients running on pre5.0 VMs, then a stub class for the remote object implementation class needs to be pregenerated using the rmic compiler, and that stub class needs to be made available for clients to download. 4/25/2018

Preparing the application (Windows system) 1. Start the registry (this will be running as a daemon) start rmiregistry *The default port number is 1099 2. Start the server 3. Run the client 4/25/2018

Basic RMI classes: /usr/java1.1/src/java/rmi java.rmi.registry.* Inside RMI http://download.oracle.com/javase/6/docs/ Basic RMI classes: /usr/java1.1/src/java/rmi java.rmi.registry.* java.rmi.Naming class (static/class methods) java.rmi.Remote interface (marker interface) java.rmi.server.* Default RMI port 1099 Both lookup from local and remote are acceptable. 4/25/2018

Implementation of RMI (5.2.5) AccessException.java RemoteException.java AlreadyBoundException.java ConnectException.java ServerException.java ConnectIOException.java ServerRuntimeException.java MarshalException.java StubNotFoundException.java UnexpectedException.jav ServerError.java UnknownHostException.java NoSuchObjectException.java UnmarshalException.java NotBoundException.java RMISecurityException.java RMISecurityManager.java Remote.java MarshalledObject.java Naming.java activation dgc Registry server 4/25/2018

RMI software Layer of software between application level objects and communication and remote reference modules: “Middleware” Proxy: provides remote access transparency. One proxy for every remote object in the client. Dispatcher: A server has one dispatcher and RemoteStub for each class representing a remote object. It receives request message from comm. module It used MessageId to select appropriate method in RemoteStub. RemoteStub and dispatcher use same MessageId. RemoteStub: A class of remote object has a that stands for the remote interface. All the access dependencies are hidden in this class. A remote object has a servant that directly implements the methods. Java 5 creates this dynamically. Binder: binds textual names to remote object references. RMIRegistry is a binder; Naming class; see fig.5.13 We will discuss this next. Server Threads: one thread per invocation Distributed garbage collection: See Andrew Birell’s paper [1995]. 4/25/2018

Simple RMI System Model Host M/C JVM Registry Client M/C server JVM server ClientApp Remote interface 4/25/2018

Registry (singleton – per system - during production) Name Mortgage Tempertur Reference 4/25/2018

Serialization Serialization is a the operation of encoding objects into stream of bytes: bytification. De-serialization is taking the bytes and constructing objects out of the byte stream. Is used to marshal and unmarshal arguments and results. If serialization is not addressed your distributed system will not work: whether it be your mobile systems or land networked system. A stumbling block for many who are new to DS. 4/25/2018

Serialization (contd.) In order for an object to be passed around in a DS it must implement Serializable interface (another marker interface: Remote was the first one we saw) For performance reasons you may want to specify the serialization version (though not required) serialVersionUID 4/25/2018

Reference For more details, check the link below http://download.oracle.com/javase/6/docs/technotes/gu ides/rmi/index.html 4/25/2018