Remote Procedure Call

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

JAVA RMI. Remote Method Invocation

Remote Method Invocation

Remote Objects and RMI

Last Class: Network Overview. Today: Distributed Systems

Distributed Computing

Generic architecture

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

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

Remote Method Invocation R.M.I.

Remote Method Invocation in Java

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

5.4. Events and notifications

CS 5523 Operating Systems: Remote Objects and RMI

presentation DAD Distributed Applications Development Cristian Toma

Distributed Systems. 5. Remote Method Invocation

Distributed Programming in Java. Distribution (2)

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

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

5 Distributed Objects: The Java Approach

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Lecture VI: Distributed Objects. Remote Method Invocation

Chapter 4 Remote Procedure Calls and Distributed Transactions

Verteilte Systeme (Distributed Systems)

Communication and Distributed Processing

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,

Distributed Objects SPL/ SPL 201 / 0 1

Remote Method Invocation

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

CSci Introduction to Distributed Systems. Communication: RPC In Practice

Communication and Distributed Processing

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

Component-Based Software Engineering

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

Remote Method Invocation

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

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

Distributed Systems COMP 212. Lecture 10 Othon Michail

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

IBD Intergiciels et Bases de Données

Distributed Software Systems

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

Distributed Information Systems

Written by: Dave Matuszek

RMI. (Remote Method Invocation)

Last Class: RPCs. Today:

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

RMI. Remote Method Invocation. 16-Dec-16

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

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

RMI Case Study. A Typical RMI Application

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

CHAPTER - 4 REMOTE COMMUNICATION

Distributed Systems. The main method of distributed object communication is with remote method invocation

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

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

Last Class: RPCs. Today:

THE UNIVERSITY OF WESTERN AUSTRALIA SAMPLE EXAM QUESTIONS 2007 WITH SOLUTIONS SCHOOL OF COMPUTER SCIENCE CITS3213 CONCURRENT PROGRAMMING (PART II)

RMI: Design & Implementation

Course Snapshot. The Next Few Classes

Chapter 4: Processes. Process Concept. Process State

Modulo II Socket, RMI e Corba

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

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

Distributed object component middleware I - Java RMI

Distributed object component middleware I - Java RMI

DISTRIBUTED COMPUTING

Chapter 5 Distributed Objects and Remote Invocation

Lecture 5: Object Interaction: RMI and RPC

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

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

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

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

RMI Example RMI. CmpE 473 Internet Programming RMI

REMOTE METHOD INVOCATION INTRODUCTION TO RMI, A JAVA API FOR RPC-STYLE INVOCATION OF REMOTE OBJECT METHODS

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

CS193k, Stanford Handout #12. Threads 4 / RMI

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

Concurrent Object-Oriented Programming

Lecture 06: Distributed Object

RPC and RMI. 2501ICT Nathan

Remote Invocation Vladimir Vlassov and Johan Montelius

IJESRT. http: //

COMP 6231: Distributed System Design

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

JAVA RMI Java, summer semester

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

Activation of remote objects

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

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

Programming with RMI Reminder

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

Activation of remote objects

Object-Oriented Distributed Technology

Distributed Systems. Communication (2) Schedule of Today. Distributed Objects. Distributed Objects and RMI. Corba IDL Example

Remote Method Invocation. Benoît Garbinato

Remote Method Invocation Benoît Garbinato

Chapter 5: Distributed objects and remote invocation


Transcription:

Remote Procedure Call Suited for Client-Server structure. Combines aspects of monitors and synchronous message passing: Module (remote object) exports operations, invoked with call. call blocks (delays caller) until serviced. call causes a new thread to be created on remote (server). Client-server synchronization and communication is implicit. c 2003, 2005 Typset March 5, 2008 1

Terminology / Notation server module: operations, (shared) variables, local procedures and threads for servicing remote procedure calls. interface (specification): describes the operations, parameter types and return types. op opname(param types) [returns return type] server process: thread created by call to service an operation. background process: threads running in a module that aren t created in response to call. c 2003, 2005 Typset March 5, 2008 2

ExampleServerModule module TicketServer op getnext returns int ; body int next := 0 ; sem ex := 1 ; procedure getnext() returns val { P(ex) ; val := next ; next := next + 1 ; V(ex) ; } end TicketServer c 2003, 2005 Typset March 5, 2008 3

Issues Lookup and registration How does the client find the server? Often server registers (binds) with a naming service (registry). Client obtains information (lookup) about server from this server. This changes the question to: How does the client find the registry? Synchronization Synchronization within a module (server). Two approaches: 1. Assume mutual exclusion in server (only one server process/background process executing at a time). Similar to monitors. Still need conditional synchronization. 2. Program it explicitly (i.e., using semaphores, monitors etc.). c 2003, 2005 Typset March 5, 2008 4

Argument passing Formats may be different on different machines. ints are different sizes, encodings, endianess. floats have different encodings Address space is different in different processes. Can not pass pointers. Can not pass by reference. Can not pass objects containing pointers. Three solutions: Copy-in: Arguments are converted to byte arrays (serialization) and reconstructed on the other side. Copy-in/copy-out: Copy-in + final value is passed back. Proxy objects: A proxy object is constructed on the server side. Calls to the proxy are converted to RPCs back to the argument. c 2003, 2005 Typset March 5, 2008 5

Java RMI (Remote Method Invocation) Client objects and server objects are local to different JVM processes. Server objects (usually) extend java.rmi.server.unicastremoteobject. Lookup and registration How does the client find the server? Server objects registered by name with a registry service. (Naming.bind) Client objects obtain references to proxy objects from the registry service. (Naming.lookup) Synchronization Synchronization within a module (server). Each remote call implies the creation of a new server thread. So if there are multiple clients, there can be multiple server threads active at the same time. Synchronization must be programmed explicitly (use synchronized or my monitor package) c 2003, 2005 Typset March 5, 2008 6

Argument passing Formats may be different on different machines. Not an issue as data formats are standard across all Java implementations. Address space is different in different processes. Reference arguments (and subsidiary references) are serialized and passed by copy-in rather than by reference. Except RemoteObjects, in which case a proxy ( stub ) is passed instead (This complicates garbage collection). c 2003, 2005 Typset March 5, 2008 7

Skeletons and Stubs Stub objects implement the same interface as the server objects. (Proxy pattern) (0), (5) Client threads call a stub local to their JVM instance. (1), (4) Stub messages (TCP/IP) to Skeleton object in remote JVM & waits for reply. (2), (3) Skeleton creates a new server thread which calls the server. StubandskeletonclassesaresynthesizedbyaRMICompiler (rmic). Call (0) Client Stub (Proxy) (5) Return Message Object (2) Server Skeleton (3) (1) Process (JVM) (4) Network c 2003, 2005 Typset March 5, 2008 8

Example Start a registry process D:\...\classes> rmiregistry -Jcp -J. First we need an interface for the server package tryrmi; import java.rmi.* ; public interface TicketServerInterface extends Remote { public int getticket() throws RemoteException ;} c 2003, 2005 Typset March 5, 2008 9

We implement the interface and write a main program to create and register the server object. package tryrmi; import java.rmi.*; import java.rmi.server.unicastremoteobject; public class TicketServer extends UnicastRemoteObject implements TicketServerInterface { private int next = 0 ; public synchronized int getticket() throws RemoteException { return next++ ; } public TicketServer() throws RemoteException { super() ; } c 2003, 2005 Typset March 5, 2008 10

public static void main( String[] args ) { try { TicketServer server = new TicketServer() ; String name = args[0] ; Naming.bind( name,server);} catch( java.net.malformedurlexception e) {... } catch( AlreadyBoundException e) {... } catch( RemoteException e){...}}} Executing main creates and registers a server object. D:\...\classes> java -cp. tryrmi.ticketserver rmi://frege.engr.mun.ca/ticket The skeleton object will be generated automatically by the Java Runtime Environment. (There is no need to write a class for the skeleton object.) Some client code package tryrmi; c 2003, 2005 Typset March 5, 2008 11

import java.rmi.* ; public class TestClient { public static void main(string[] args) { try { String name = args[0] ; TicketServerInterface proxy = (TicketServerInterface) Naming.lookup( name); use proxy object} catch( java.net.malformedurlexception e) {... } catch( NotBoundException e) {... } catch( RemoteException e) {... } } } The client can be executed from anywhere on the internet. (The stub object will be created by the Java Runtime Environment. There is no need to write a class for the stub object.) D:\...\classes> java -cp. tryrmi.testclient rmi://frege.engr.mun.ca/ticket c 2003, 2005 Typset March 5, 2008 12

RPC 6= PC Although remote procedure calls and local procedure calls are beguilingly similar and in Java share exactly the same syntax, there are important differences Partial Failure Partofthesystemofobjectsmayfail Partial failures may be intermittent Network delays On a large network, delays are indistinguishable from failures Performance Remote calls are several orders of magnitude more expensive than local calls (100,000 or more to 1) Concurrency Remote calls introduce concurrency that may not be in a nondistributed system. Semantics changes In Java, local calls pass objects by reference. Remote calls pass objects either by copy or by copying a proxy. c 2003, 2005 Typset March 5, 2008 13