Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.

Slides:



Advertisements
Similar presentations
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)
Advertisements

Remote Procedure Call Design issues Implementation RPC programming
Distributed Objects and Remote Invocation
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
Distributed Object & Remote Invocation Vidya Satyanarayanan.
Remote Method Invocation
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.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
Introduction to Remote Method Invocation (RMI)
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
.NET Mobile Application Development Remote Procedure Call.
Slides for Chapter 5: Communication between distributed objects
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
CS425 /CSE424/ECE428 – Distributed Systems – Fall Nikita Borisov - UIUC1 Material derived from slides by I. Gupta, M. Harandi, J. Hou, S.
Communication between distributed objects Remote procedure call
Information Management NTU Interprocess Communication and Middleware.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Client Call Back Client Call Back is useful for multiple clients to keep up to date about changes on the server Example: One auction server and several.
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.
DISTRIBUTED OBJECTS AND REMOTE INVOCATION. Introduction This chapter is concerned with programming models for distributed applications... Familiar programming.
IS473 Distributed Systems CHAPTER 5 Distributed Objects & Remote Invocation.
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
Distributed Objects & Remote Invocation
Slides for Chapter 5: Distributed objects and remote invocation From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition.
Remote Method Invocation A Client Server Approach.
1 Distribuerede systemer og sikkerhed – 28. februar 2002 From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley.
Lecture 8-1 Computer Science 425 Distributed Systems CS 425 / ECE 428 Fall 2013 Indranil Gupta (Indy) September 19, 2013 Lecture 8 RPCs and Distributed.
Distributed objects and remote invocation Pages
Netprog Java RMI1 Remote Method Invocation.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Distributed Systems Lecture 8 RPC and marshalling 1.
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
03 – Remote invoaction Request-reply RPC RMI Coulouris 5
Communication between distributed objects Remote procedure call
Java Distributed Computing
CSE 486/586 Distributed Systems Remote Procedure Call
Remote Method Invocation
What is RMI? Remote Method Invocation
Communication between distributed objects Remote procedure call
Remote Method Invocation
Distributed Systems Course Topics in distributed objects
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
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
Slides for Chapter 5: Distributed objects and remote invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Creating a Distributed System with RMI
Remote method invocation (RMI)
Distribution Infrastructures
Creating a Distributed System with RMI
Remote invocation (call)
Java Remote Method Invocation
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Creating a Distributed System with RMI
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University

Outline Programming models for distributed applications Distributed objects Java RMI case study Distributed event-based systems

Programming models for distributed applications Requirement: –processes need to be able to invoke operations in other processes Applications, services Middleware layers request-reply protocol marshalling and external data representation UDP and TCP This lecture RMI, RPC, and events

Programming models (contd.) Remote procedure call –provide clients with the ability to call procedures in server programs running in separate processes, likely on different computers Remote method invocation –allowing objects to invoke methods of objects that can be in different processes and on different computers Event-based programming –objects can receive notifications from other possibly remote objects about events they are interested in – essentially distributed event-driven programming

Object-oriented programming Objects: –encapsulation of data and code operating on that data Object reference: –a pointer to an object –String s = new String(); Interfaces: –methods, their arguments, return values and exceptions (aka method signatures) –int getValue(String attribute) throws Exception

Object-oriented programming Actions: –initiated by object invoking method of another object Exceptions: –a mechanism for handling error –control passes to a block of code that catches the exception Garbage collection: –Reusing memory occupied by objects that are no longer needed – object references are used to determine that! –In some languages, programmers have to do it manually

What about distributed objects? Can adopt the client-server architecture: invocation remote invocation remote local invocation A B C D E F ClientServer (managing remote objects) Request to call a method on a remote object is sent to server in a message (result is returned back to client in another message) © Pearson Education 2005

Distributed object model Remote object reference: –a mechanism to access (identify) a remote object –a unique identifier that can be used throughout a distributed system Remote interface: –a way to specify what the remote object signature is like (which methods we can call, what are inputs and outputs?) interface remote m1 m2 m3 m4 m5 m6 Data implement. remoteobject { of methods © Pearson Education 2005

Distributed object model (contd.) Actions: –like in non-distributed – initiated by method invocations (except these can be remote now) Garbage collection: –More tricky! –Local garbage collector need to have information about remote references to its objects –Need to count local as well as remote references to an object. Exceptions: –need to transfer back to the client –additional sources of exceptions (server crashes, network failures)

Design issues for RMI Invocation semantics (meaning): –Recall: messages can get lost, processes can crash Fault tolerance measures Invocation semantics Retransmit request message Duplicate filtering Re-execute procedure or retransmit reply No Yes Not applicable No Yes Not applicable Re-execute procedure Retransmit replyAt-most-once At-least-once Maybe

RMI implementation Proxy: makes invocation transparent for client -- remote referencing, marshalling request, sending it to server, unmarshalling response Dispatcher: passes request message to the requested skeleton method Skeleton: the opposite of proxy – unmarshalling request, calling remote object, marshalling and sending back response object A object B skeleton Request proxy for B Reply Communication Remote Remote reference Communication module reference module module for B’s class & dispatcher remote client server © Pearson Education 2005

Java RMI Client object RMI stub RMI dispatcher and skeleton Remote object RMI registry Client Server Remote reference module Proxy

Making remote service Make remote interface –public interface MyRemote { … Make implementation of remote class –public class MyRemoteImpl implements MyRemote {.. Start RMI registry on the server –rmiregistry Start remote service –java MyRemoteImpl

Making remote interface import java.rmi.*;... public interface MyRemote extends Remote {... public String sayHello() throws RemoteException;... } Need to announce that this is a remote interface Errors occurring during remote invocation Input/return values must be Serializable, since they will be sent over network Contains definitions of necessary classes etc

Making remote implementation import java.rmi.*;... public class MyRemoteImpl extends UnicastRemoteObject implements MyRemote {... public MyRemoteImpl() throws RemoteException { };... public String sayHello() throws RemoteException { return “Server says hello!”); }... } This is to include functionality needed to work as a remote object Implementation of the remote method UnicastRemoteObject throws RemoteException in its constructor – so we have to do the same in our class Contains definitions of necessary classes etc

In the main method of your service class… Need to instantiate the class Need to give it an RMI name – so that clients could access it by this name through the RMI registry... try { MyRemote service = new MyRemoteImpl(); Naming.rebind(“Remote hello”, service); } catch (Exception e) {... }... This registers your object with RMI registry

Generating stubs and skeletons In olderJava versions: –Use rmic –Produces a new class Stub: _Stub even older Java versions also produced a separate skeleton class _Skel In newer Java version (1.5 and later): –Generated automatically at run time MyRemoteImpl_Stub.class

What about the client code? Client need to do two steps to call a remote object: –Get remote reference (in this case reference to the corresponding RMI stub) –Call it!... try { MyRemote service = (MyRemote) Naming.lookup(“rmi://localhost/Remote hello”); String s = service.sayHello();... } catch (Exception e) {... }... RMI name of the remote object Host where the server is running

What actually happens… Client object RMI stub RMI dispatcher Remote object RMI registry: Client Server NameStub Remote hello RMI stub lookup() stub returned sayHello()

A note on which files you will need on client and server On client: –Your client class –Remote interface class (MyRemote.class) On server: –Remote interface class (MyRemote.class) –Remote class implementation (MyRemoteImpl.class) In older Java versions, also needed stub class (MyRemoteImpl_Stub.class) on both server and client –Why would we need stub class on the client?

Remote Procedure Call (RPC) The same idea as RMI –Client-server –Stubs and skeletons (clients and server stub procedures) –Communication modules and dispatcher on the server Have a look for examples, at the Sun RPC case study in the book

Event-based programming Program execution is driven by external events as opposed to a pre-programmed sequence: What is the most common application? Distributed even-based systems –Extend the local event model by allowing objects at different locations to be notified of events taking place at an object While (forever) { // Wait for next event // Send notification to all interested objects }

Distributed event-based systems How the communication happens –Receiving object needs to register its interest in a type of event (subscribe to a particular type of event) Characteristics: –Heterogeneous Objects can interoperate even when they were not designed to work together explicitly –Asynchronous Objects generating events do not have to synchronise with objects that subscribe to those events

Example: Stock dealing system © Pearson Education 2005

Participants in distributed event notification Object of interest – source of events Event – some change in an object of interest (usually a result of method execution) Notification – an object that contains information about an event (its type and other attributes) Subscriber – an object interested in some type of events Observer – intermediary decoupling event source and subscriber (forwarding, filtering, patterns of events, mailboxes) Publisher – object declaring that it will generate notifications (either the object of interest or an observer)

Architectures for event notification subscriberobserverobject of interest Event service object of interest observer subscriber notification © Pearson Education 2005

Example: Jini A distributed Java-based computing environment that can offer ``network plug and play'‘. Examples: –A new printer, digital camera, etc.. can be connected to the network and announce its presence and capabilities. A client can then use this printer without having to be specially configured to do so and the camera can send pictures to the printer.

Summary Centralised: procedure call, method invocation, event-based programming Distributed: RPC, RMI, distributed event-based programming Adopt the client-server architecture –stubs (proxies), dispatchers, skeletons –exceptions (errors), garbage collection –Example: Java RMI Questions