Distributed Computing Class: BIT5 Instructor: Aatif Kamal Chapter 05: Distributed Objects and Remote Invocation Dated: Nov 2006.

Slides:



Advertisements
Similar presentations
CSE 486/586 Distributed Systems Remote Procedure Call
Advertisements

Remote Procedure Call (RPC)
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.
Lecture 8-1 Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428 Fall 2012 Indranil Gupta (Indy) September 20, 2012 Lecture 8 RPCs and Distributed.
Distributed Object & Remote Invocation Vidya Satyanarayanan.
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.
Two Approaches yCommunication-Oriented Design Begin with the communication protocol. Design a message format and syntax. Design the client and server components.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
CORBA Case Study By Jeffrey Oliver March March 17, 2003CORBA Case Study by J. T. Oliver2 History The CORBA (Common Object Request Broker Architecture)
Introduction to Remote Method Invocation (RMI)
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
Notes from “Distributed Systems Concepts and Design” by Coulouris
Chapter 5: Distributed objects and remote invocation
Slides for Chapter 5: Communication between distributed objects
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
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.
Sun RPC also called ONC (Open Network Computing) RPC originally designed for client-server communication for Sun Network File System (NFS) provides an.
Chapter 4: Interprocess Communication‏ Pages
Lecture 15-1 Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428 Fall 2010 Indranil Gupta (Indy) October 12, 2010 Lecture 15 RPCs and Distributed.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Lecture 5: RPC and Distributed Objects Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
 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.
CS 425/ECE 428/CSE 424 Distributed Systems (Fall 2009) Lecture 18 Distributed Objects (II) Sections , Chapter
Distributed Objects & Remote Invocation
Distributed Objects and Remote Invocation Source: George Colouris, Jean Dollimore, Tim Kinderberg & Gordon Blair (2012). Distributed Systems: Concepts.
1 Distributed Objects and Remote Invocation – 5.1 Introduction  Foci: –Communication among distributed objects via RMI  Recipients of remote invocations.
Remote Procedure Call RPC
Computer Science Lecture 3, page 1 CS677: Distributed OS Last Class: Communication in Distributed Systems Structured or unstructured? Addressing? Blocking/non-blocking?
DISTRIBUTED OBJECTS AND REMOTE INVOCATION 1. 2 Topics  Middleware  Remote Method Invocation  Remote Procedure Call.
Slides for Chapter 5: Distributed objects and remote invocation From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition.
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
© 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.
Computer Science Lecture 4, page 1 CS677: Distributed OS Last Class: RPCs RPCs make distributed computations look like local computations Issues: –Parameter.
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
RPC 6/14/20161BALAJI K - AP. Design issues of RPC Programming with interfaces Call Semantics associated with RPC Transparency and related to procedure.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
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
CSE 486/586 Distributed Systems Remote Procedure Call
Communication between distributed objects Remote procedure call
Edition 5, © Addison-Wesley 2012
Distributed Systems Course Topics in distributed objects
Programming Models for Distributed Application
DISTRIBUTED COMPUTING
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Slides for Chapter 5: Distributed objects and remote invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Remote method invocation (RMI)
Distribution Infrastructures
Remote invocation (call)
Java Remote Method Invocation
Last Class: Communication in Distributed Systems
Presentation transcript:

Distributed Computing Class: BIT5 Instructor: Aatif Kamal Chapter 05: Distributed Objects and Remote Invocation Dated: Nov 2006

2 Objectives of the lecture Essence of distributed commuting To study communication between distributed objects and the integration of remote method invocation into a programming language. To be able to use Java RMI to program applications with distributed objects and how to use some aspects of reflection To study the extension of the event-based programming model to apply to distributed event-based programs.

3 Revision Two alternative building blocks Datagram Socket: based on UDP, efficient but suffer from failures Stream Socket: based on TCP, reliable but expensive Marshalling CORBA’s CDR and Java serialization Request-Reply protocol Base on UDP or TCP Group communication IP multicast is a simple multicast protocol

4 Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary Chapter 5: Distributed objects and remote invocation

5 Layers of MiddlewareMiddleware Provide a programming model Provide transparency Location Communication protocols Computer hardware Operating systems Programming languages Middleware

6 Middleware layers Applications Middleware layers Request reply protocol External data representation Operating System RMI, RPC and events

7 Remote procedure call (RPC) Birrel and Nelson (1984) call procedure in separate process Remote method invocation (RMI) extension of local method invocation in OO model invoke the methods of an object of another process Event-based model Register interested events of other objects Receive notification of the events at other objects Distributed programming model

8 Conventional Procedure Call a) Parameter passing in a local procedure call: the stack before the call to read b) The stack while the called procedure is active

9 Client and Server Stubs Principle of RPC between a client and server program.

10 Steps of a Remote Procedure Call 1. Client procedure calls client stub in normal way 2. Client stub builds message, calls local OS 3. Client's OS sends message to remote OS 4. Remote OS gives message to server stub 5. Server stub unpacks parameters, calls server 6. Server does work, returns result to the stub 7. Server stub packs it in message, calls local OS 8. Server's OS sends message to client's OS 9. Client's OS gives message to client stub 10. Stub unpacks result, returns to client

11 Passing Value Parameters (1) Steps involved in doing remote computation through RPC 2-8

12 Passing Value Parameters (2) a) Original message on the Pentium b) The message after receipt on the SPARC c) The message after being inverted. The little numbers in boxes indicate the address of each byte

13 Interface Specifies accessible procedures and variables Inner alteration won’t affect the user of the interface Interface in distributed system Can’t access variables directly Input argument and output argument Pointers can’t be passed as arguments or returned results Interfaces

14 RPC’s Service interface specification of the procedures of the server input and output arguments of each procedure RMI’s Remote interface Specification of the methods of an object that are available for objects in other processes may pass objects or remote object references as arguments or returned result Interface definition languages program language, e.g. Java RMI Interface definition language (IDL), e.g. CORBA IDL, DCE IDL and DCOM IDLCORBA IDL Interface cases

15 CORBA IDL example // In file Person.idl struct Person { string name; string place; long year; } ; interface PersonList { readonly attribute string listname; void addPerson(in Person p) ; void getPerson(in string name, out Person p); long number(); };

16 Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary Chapter 5: Distributed objects and remote invocation

17 The object model Distributed objects The distributed object model Design issues semantics of remote invocations Implementation RMI above the request-reply protocol Distributed garbage collections Discuss RMI under following headings

18 The object model Object references Objects can be accessed via object references First-class values Interfaces A definition of the signatures of a set of methods No constructers A class can implement several interfaces, e.g. Java Actions Initiated by an object invoking a method in another object Two affects Change the state of the receiver Further invocations on methods in other objects

19 Exceptions mechanism A clean way to deal with error conditions List exceptions at the method head throw user know exceptions Catch exceptions Garbage collection Freeing the space occupied by cancelled objects C++: collected by programmers Java: collected by JVM The object model

20 Distributed objects Natural extension physical distribution of objects into different processes or computers in a distributed system Benefits of distributed objects Enforce encapsulation can’t access variables directly Support heterogeneous systems Assume other architectural models then client/server Replicated objects Migrated objects

21 Remote and local method invocations invocation remote invocation remote local invocation A B C D E F

22 The distributed objects model Remote object reference A unique identifier in a distributed system May be passed as arguments and results of remote method invocation Remote interface remote object class implements the methods of its remote interface Actions in a distributed systems may incur a chain of invocations on different computers Garbage collection Usually based on reference counting Exception notify the client and the client handle exceptions

23 A remote object and its remote interface interface remote m1 m2 m3 m4 m5 m6 Data implementation remoteobject { of methods

24 Design Issues – Invocation semantics Choices for different delivery guarantees retry request message duplicate filtering retransmission of results Three different semantics 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

25 Different invocation semantics Maybe For invoker: executed once, or not at all ??? Suffer from: (1) message lost; (2) server crash Useful for app. in which occasional failed invocation are acceptable At least once For invoker: execute at least once, or an exception Suffer from: (1) server crash; (2) arbitrary failures for non- idempotent method At most once For invoker: receives result, or an exception Prevent: omission failures by retrying, arbitrary failures

26 Design Issues - Transparency What can be made transparent marshaling message passing object locating and contacting What can’t be made transparent vulnerable to failure latency Current consensus(Jim Waldo research paper) Syntax of remote invocation should be same as of local invocation Difference in remote and local objects should be expressed in their interfaces

27 Implementation of RMI The inner scene of RMI Communication module Request/reply between client and server As discussed in chapter 4, figure 4.13figure 4.13 Communication module at Server side Select dispatcher at server Remote reference module Translate between local and remote object reference Create remote object reference Remote object table entries for remote objects held by the process entries for local proxies Actions of RRM When a remote object is to be passed as argument or result for the first time the remote reference module is asked to create a remote object reference, which it adds to its table When a remote object reference arrives in a request or reply message, the remote reference module is asked for the corresponding local object reference, which may either refer to proxy or remote object

28 Request-reply message structure (fig 4.13) messageType requestId objectReference methodId arguments int (0=Request, 1= Reply) int RemoteObjectRef int or Method array of bytes

29 The role of proxy and skeleton in remote method invocation 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

30 Implementation of RMI – RMI software Proxy forward invocation to remote object one remote object one proxy implement the method in the remote interface It marshals a reference to the target object, its own methodId and its arguments into request message and send it to the target, awaits the reply and message, unmarshals it and returns the results to invoker Skeleton implement the method in the remote interface unmarshal the arguments in the request invoke the corresponding method in the remote object wait for the invocation complete marshal the result in the reply message Dispatcher Receive the request from communication module and select appropriate method in the skeleton one dispatcher and skeleton for one remote object

31 Implementation of RMI - execution The classes for proxies, dispatchers and skeletons generated automatically by an interface compiler, e.g. rmic Server program create and initialize at least one of the remote objects register Client program look up the remote object references Invoke Factory methods Remote object interface cannot have constructors Remote objects are either created in initialization section or in remote methods designed for that purpose, called factory methods

32 Implementation of RMI - Object state The binder A service that maintains mapping information of textual names to remote object references Activation of remote objects to avoid resource waste, the servers can be started whenever they are needed- FTP service Activators: process that start server processes to host remote objects. a remote object could be active or passive Passive object: consist of two parts Implementation of its methods Its state in marshaled form Activation: Making a new object from corresponding passive object by creating a new instance of its class and initializing its variables from the stored state Java RMI uses one activator on each server computer, which is responsible for activating objects on that computer.

33 Implementation of RMI - Object state (cont..) Persistent object stores Persistent object an object that is guaranteed to live between activations of processes Persistent Object Store Manage and store the state of persistent objects different passivate strategies at the end of a transaction when the program exit E.g., Persistent Java, PerDiS

34 Distributed garbage collection The aim of a distributed garbage collector Retain the object (local&remote) when it is still be referenced Collect the object when none holds reference to it Java distributed garbage collection algorithm based on reference counting Whenever a remote object enters a process, a proxy is created and will stay there for as long as needed. The process where the actual object lives (server) should be informed, then later when there is no longer a proxy at the client, server should be informed Distributed Garbage collection works in corporation with local garbage collectors server maintain processes set that hold remote object references to it for each of its remote objects client notify server to modify the process set when the process set becomes empty, server local garbage collector reclaims the space

35 Distributed garbage collection (cont..) Leases in Jini lease: the granting of the use of a resource for a period of time avoid to discover whether the resource users are still interested or their programs have not exited

36 Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary Chapter 5: Distributed objects and remote invocation

37 RPC is very similar to RMI Service interface: the procedures that are available for remote calling Invocation semantics choice: at-least-once or at-most-once Generally implemented over request-reply protocol Building blocks Communication module Client stub procedure (as proxy in RMI): marshalling, sending, unmarshalling Dispatcher: select one of the server stub procedures Server stub procedure (as skeleton in RMI): unmarshalling, calling, marshalling client Request Reply Communication module dispatcher service client stub server stub procedure client processserver process procedure program

38 Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary Chapter 5: Distributed objects and remote invocation

39 Event-notification model Idea one object react to a change occurring in another object Event examples modification of a document A new doc added in an electronically tagged book Publish/subscribe paradigm event generator publish the type of events event receiver subscribe to the types of events that are interest to them When event occur, notify the receiver Distributed event-based system – two characteristics Heterogeneous asynchronous

40 Example - dealing room system Requirements –allow dealers to see the latest market price information System components –Information provider receive new trading information publish stocks prices event stock price update notification –Dealer process subscribe stocks prices event System architecture

41 Dealing room system

42 Architecture for distributed event notification Event service: maintain a database of published events and of subscribers’ interests decouple the publishers from the subscribers subscriberobserverobject of interest Event service object of interest observer subscriber notification

43 The roles of the participating objects The object of interest its changes of state might be of interest to other objects Event the completion of a method execution Notification an object that contains information about an event Subscriber an object that has subscribed to some type of events in another object Observer objects the main purpose is to decouple an object of interest from its subscribers Publisher an object that declares that it will generate notifications of particular types of event

44 Notification delivery Delivery semantics Unreliable Reliable real-time Roles for observers Forwarding send notifications to subscribers on behalf of one or more objects of interests Filtering of notifications Patterns of events Notification mailboxes notification be delayed until subscriber being ready to receive

45 Jini distributed event specification EventGenerator interface Provide register method Event generator implement it Subscriber invoke it to subscribe to the interested events RemoteEventListener interface Provide notify method subscriber implement it receive notifications when the notify method is invoked RemoteEvent a notification that is passed as argument to the notify method Third-party agents interpose between an object of interest and a subscriber equivalent of observer

46 Introduction Communication between distributed objects Remote procedure call Events and notifications RPC Case Study Java RMI case study Summary Chapter 5: Distributed objects and remote invocation

47 Sun RPC case study (1) Designed for NFS at-least-once semantics XDR - Interface definition language Interface name: Program number, version number Procedure identifier: procedure number Rpcgen – generator of RPC components client stub procedure server main procedure Dispatcher server stub procedure marshalling and unmarshalling procedure

48 Sun RPC case study (2) Binding – portmapper Server: register ((program number, version number), port number) Client: request port number by (program number, version number) Authentication Each request contains the credentials of the user, e.g. uid and gid of the user Access control according to the credential information

49 Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary Chapter 5: Distributed objects and remote invocation

50 Java RMI introduction Remote object Must implement the remote interface must handle remote exceptions Arguments and return results of remote method Must be serializable All primitive types serializable remote objects are serializable File handles are unserializable Remote objects are passed as remote object reference, non- remote serializable objects are copied and passed by value RMIregistry access by the Naming class

51 Example: shared whiteboard Remote Interface Server program and Client program Callbacks A server’s action of notifying clients about an event Implementation Client create a remote object Client pass the remote object reference to server Whenever an event occurs, server call client via the remote object Advantage Improve performance by avoid constant polling Delivery information in a timely manner

52 Design and implementation of Java RMI Java classes supporting RMI RemoteServer UnicastRemoteObject Activatable RemoteObject

53 Introduction Communication between distributed objects Remote procedure call Events and notifications Java RMI case study Summary Chapter 5: Distributed objects and remote invocation

54 Summary Two paradigms for distributed programming RMI(RPC)/Event notification: sync./async. RMI Distributed object model Remote interface, remote exception, naming service Remote invocation semantics Once, at-least-once, at-most-once Sun RPC Event-notification Publish/subscribe Event service Example: dealing room

55 Files interface in Sun XDR const MAX = 1000; typedef int FileIdentifier; typedef int FilePointer; typedef int Length; struct Data { int length; char buffer[MAX]; }; struct writeargs { FileIdentifier f; FilePointer position; Data data; }; struct readargs { FileIdentifier f; FilePointer position; Length length; }; program FILEREADWRITE { version VERSION { void WRITE(writeargs)=1;1 Data READ(readargs)=2;2 }=2; } = 9999;

56 The Naming class of Java RMIregistry void rebind (String name, Remote obj) This method is used by a server to register the identifier of a remote object by name, as shown in Figure 15.13, line 3. void bind (String name, Remote obj) This method can alternatively be used by a server to register a remote object by name, but if the name is already bound to a remote object reference an exception is thrown. void unbind (String name, Remote obj) This method removes a binding. Remote lookup(String name) This method is used by clients to look up a remote object by name, as shown in Figure line 1. A remote object reference is returned. String [] list() This method returns an array of Strings containing the names bound in the registry.

57 Java Remote interfaces Shape and ShapeList import java.rmi.*; import java.util.Vector; public interface Shape extends Remote { int getVersion() throws RemoteException; GraphicalObject getAllState() throws RemoteException;1 } public interface ShapeList extends Remote { Shape newShape(GraphicalObject g) throws RemoteException;2 Vector allShapes() throws RemoteException; int getVersion() throws RemoteException; }

58 Java class ShapeListServant implements interface ShapeList import java.rmi.*; import java.rmi.server.UnicastRemoteObject; import java.util.Vector; public class ShapeListServant extends UnicastRemoteObject implements ShapeList { private Vector theList; // contains the list of Shapes1 private int version; public ShapeListServant()throws RemoteException{...} public Shape newShape(GraphicalObject g) throws RemoteException {2 version++; Shape s = new ShapeServant( g, version);3 theList.addElement(s); return s; } public Vector allShapes()throws RemoteException{...} public int getVersion() throws RemoteException {... } }

59 Java class ShapeListServer with main method import java.rmi.*; public class ShapeListServer{ public static void main(String args[]){ System.setSecurityManager(new RMISecurityManager()); try{ ShapeList aShapeList = new ShapeListServant();1 Naming.rebind("Shape List", aShapeList );2 System.out.println("ShapeList server ready"); }catch(Exception e) { System.out.println("ShapeList server main " + e.getMessage());} }

60 Java client of ShapeList import java.rmi.*; import java.rmi.server.*; import java.util.Vector; public class ShapeListClient{ public static void main(String args[]){ System.setSecurityManager(new RMISecurityManager()); ShapeList aShapeList = null; try{ aShapeList = (ShapeList) Naming.lookup("//bruno.ShapeList");1 Vector sList = aShapeList.allShapes();2 } catch(RemoteException e) {System.out.println(e.getMessage()); }catch(Exception e) {System.out.println("Client: " + e.getMessage());} }

61 Callback mechanism in the whiteboard system Client created remote object: Public interface WhiteboardCallback implements Remote{ void callback(int version) throws RemoteException; } Methods added in Shapelist interface: Int register(WhiteboardCallback callback) throws RemoteException; Void deregister(int callbackID) throws RemoteException;

62 Assignment 6 Q.1 From the book: Distributed Operating Systems, A. S. Tanenbaum, Summarize section 2.4 in you own words Q.2 Read the following paper: and summarizes in your own words. Finally give your own comments on the issues discussed in the paper. A Note on Distributed Computing, Jim Waldo Sun Microsystems site: After carefully reading and understanding the article you have too write one page overview of this note.

63 Assignment 7 Q Q Q Q.4 5.5

64 Assignment 8 Q Q Q Reading 5.3 RPC 5.5 Java RMI case study