1 Remote Procedure Calls (RPC) and Distributed Objects G53ACC Chris Greenhalgh.

Slides:



Advertisements
Similar presentations
1 Communication in Distributed Systems REKs adaptation of Tanenbaums Distributed Systems Chapter 2.
Advertisements

RPC Robert Grimm New York University Remote Procedure Calls.
Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
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.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
Implementing Remote Procedure Calls Andrew Birrell and Bruce Nelson Presented by Kai Cong.
Remote Method Invocation
Distributed Systems Lecture #3: Remote Communication.
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.
Tutorials 2 A programmer can use two approaches when designing a distributed application. Describe what are they? Communication-Oriented Design Begin with.
CORBA Case Study By Jeffrey Oliver March March 17, 2003CORBA Case Study by J. T. Oliver2 History The CORBA (Common Object Request Broker Architecture)
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
Sockets  Defined as an “endpoint for communication.”  Concatenation of IP address + port.  Used for server-client communication.  Server waits for.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
Communication in Distributed Systems –Part 2
.NET Mobile Application Development Remote Procedure Call.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
1 G52IWS: Distributed Computing Chris Greenhalgh.
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
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.
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W. Grundke.
Chapter 4: Interprocess Communication‏ Pages
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.
Distributed Programming CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
 Remote Procedure Call (RPC) is a high-level model for client-sever communication.  It provides the programmers with a familiar mechanism for building.
IT 344: Operating Systems Winter 2008 Module 19 Networking & Remote Procedure Call (RPC) Chia-Chi Teng CTB 265.
CSE 451: Operating Systems Winter 2015 Module 22 Remote Procedure Call (RPC) Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
IS473 Distributed Systems CHAPTER 5 Distributed Objects & Remote Invocation.
Page 1 Remote Procedure Calls Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Hwajung Lee.  Interprocess Communication (IPC) is at the heart of distributed computing.  Processes and Threads  Process is the execution of a program.
Shuman Guo CSc 8320 Advanced Operating Systems
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
Remote Procedure CallCS-502 Fall Remote Procedure Call (continued) CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System.
Eric Tryon Brian Clark Christopher McKeowen. System Architecture The architecture can be broken down to three different basic layers Stub/skeleton layer.
Remote Procedure Call RPC
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Computer Science Lecture 3, page 1 CS677: Distributed OS Last Class: Communication in Distributed Systems Structured or unstructured? Addressing? Blocking/non-blocking?
G.v. Bochmann, revised Jan Comm Systems Arch 1 Different system architectures Object-oriented architecture (only objects, no particular structure)
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 2, 3: Communication 1/30/20161Distributed Systems - COMP 655.
Distributed objects and remote invocation Pages
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.
Lecture 5: RPC (exercises/questions). 26-Jun-16COMP28112 Lecture 52 First Six Steps of RPC TvS: Figure 4-7.
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.
03 – Remote invoaction Request-reply RPC RMI Coulouris 5
Prof. Leonardo Mostarda University of Camerino
CSE 486/586 Distributed Systems Remote Procedure Call
Remote Method Invocation
Programming Models for Distributed Application
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Spring 2012 Module 22 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Distribution Infrastructures
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 7: RPC (exercises/questions)
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

1 Remote Procedure Calls (RPC) and Distributed Objects G53ACC Chris Greenhalgh

2 Contents l Local procedure calls l Remote Procedure Call Model l Implementation Issues –Transparency –Binding –Heterogeneity –Concurrency l Making a Remote Procedure Call –Stubless RPC l Distributed Objects

3 Books l Comer (4 th ed) Chapter 38 l Farley Chapter 3

4 Remote Procedure Calls l High level representation of Inter Process Communication –To transfer information –To invoke an action in a remote process l Natural fit with client-server approach l Uses the normal procedure call metaphor and programming style l Calls a procedure in another process

5 A “C” function call (cf. Java static [class] method invocation) int main() { int a=10; int b=20; int result; result=add_numbers(a,b) } int add_numbers (int a, int b) { return a+b; } Process X 1

6 What is a procedure call? l A general abstraction mechanism in imperative programming languages l Parameterised “language extension” l Defined by an interface which specifies: –the name of the operation –the arguments to be passed l In some systems their direction, e.g. in/out/inout –In is typically the default and/or only option (e.g. RMI) –the type of results to be returned

7 The procedure call interface Caller example (x1,...,xn); Callee example (y1,...,yn) {... } A procedure call must specify the argument and return types. A remote procedure call must also specify which process to locate the procedure in. Interface tr example(t1,...,tn)

8 Making a local procedure (or method) call… l A local procedure call: –Copies the arguments onto the stack l (or “invocation record”) –Allocates space for the return results –Calls the procedure: l Preserves the address of the next instruction on the stack l Sets the program counter to the start of the called function…

9 Making a local procedure call (2) l Called function starts to execute: –Access arguments according to their position on the stack l Has access to the same stack/invocation record –Copies a return value into registers or onto the stack –Restores the program counter to the value placed on the stack by the caller… l Which resumes execution: –Collects result from the stack –Tidies up stack

10 A remote procedure call int main() { int a=10; int b=20; int result; result=add_numbers(a,b) } int add_numbers (int a, int b) { return a+b; } Process Y Process X 1

11 RPC Interface l Flows 1 and 3 are identical in both cases –but each must be a different thread/process l Flow 2: call jumps from process X to Y l Flow 4: return jumps from process Y to X l => Corresponds to two network messages (2 and 4) plus control over execution

12 Local procedure call structure Process/Application A procedure call interface Callee Caller

13 RPC version Callee Process/Application B Caller Process/Application A RPC support Remote Procedure Call standard(?) protocol (typically over a TCP/IP connection) Identical procedure call interface Request   Response networking RPC support networking “middleware”

14 Implementation Issues l Transparency l Binding l Heterogeneity l Concurrency

15 Implementation Issues 1: Transparency l Def. “Hiding” from the programmer whether a particular procedure call is local or remote, or which machine it runs on. –Does/should the programmer “care” whether a call was local or remote? –Is it even possible to discover this?

16 Transparency l Pro: No “special”/extra knowledge or information required to –Write a distributed application –Understand a distributed program

17 Transparency l But… –More things can go wrong in the remote case: l Partial failure: server – no answer? l Partial failure: client – not worth continuing? l Network failure: cannot communicate request and/or response –In general the program may need to deal with these…

18 Transparency l Ideal?! –Make it as much like a local procedure as possible –Minimise the situations in which extra knowledge is required –Provide facilities for programmer to access “hidden” details if required l [Forward reference: Java RMI remote methods throw RemoteException]

19 Achieving transparency l “Stub” code on client –Generated by RPC tools –Has same interface as remote procedure –  called in exactly the same way l Same name l Same arguments on stack l Same return type

20 Achieving transparency l Similar “Stub” or “skeleton” code on server –Also generated by RPC tools –Calls the remote procedure body in the same way as a normal procedure call l Same name l Same arguments on stack l Same return type

21 Other Unavoidable Differences l No shared memory between caller and callee –Arguments and results are copied across the network –So changes made to arguments in callee are not visible to caller l Unless RPC system supports in/out & out arguments, which are copied back to the callee [not JavaRMI] –Result object cannot be a direct reference to an argument – will be a copy –Methods are invoked on the local copy l [unless they are themselves distribution/remote objects] l Binding must be specified – see next issue

22 Implementation Issues 2: Binding l A local procedure call is satisfied in the local process: –linker matches procedure names –fills in process-local address of procedure l An RPC allows us to call a procedure in another process: –How is an appropriate remote procedure located? –How do we specify (i.e. name) it? –How do we communicate with it at the network layer?

23 Binding l Option 1: use some configuration option or additional support API to specify the remote procedure –Con: extra API, different to local case l Option 2: change the interface to include extra information –Con: different interface to local case l But object-oriented method invocations already have an explicit target!

24 Distributed Objects l Remote Prodedure Call becomes Remote Method Invocation –i.e. methods can be invoked on objects which are [ultimately] in another process. l Access and location transparency: just another method invocation, but… –Local object references are ultimately obtained by instantiating an object (or loading a class) in the local process. –Remote object references are obtained from the distributed object system itself. –More things can still go wrong (see “transparency”)

25 Implementation Issues 3: Heterogeneity l Def. Allowing RPCs/RMIs between processes on different machines –different operating systems –different data representation l little endian vs big endian representations l integer and other type sizes and representations l character sets

26 Heterogeneity: Specifying the Interface l For describing the data structures (requests, responses, arguments, results) being passed in an RPC we can use either: –a platform and programming language- independent specification language, e.g. l OSI has ASN.1 l Internet (e.g. NFS) has XDR l OMG CORBA has (an) IDL l COM/DCOM IDL –a particular programming language, e.g. l Java for RMI

27 Heterogeneity l The interface definition (and/or data representation) language allows us to: –translate a language and platform specific data structure into a standard sequence of bytes (“marshall”) –translate those bytes back into an equivalent data structure (at the other end) (“unmarshall”) l Byte sequences are used in the lower layers of the implementation and on the network l Native structures used in the higher layers – the actual procedure/method call(s)

28 Implementation Issues 4: Concurrency l A local procedure call has one thread ( –I.e. flow of control or virtual CPU l Threads are local to a single process –(excepting some specialised distributed OSs) l So an RPC has (at least) two threads –caller thread –callee thread

29 Concurrency l Server side has a dispatcher –with its own thread(s). l The dispatcher calls the appropriate function stub with the data bytes –gives the stub a thread of control to execute l Client thread may block waiting for results –Synchronous (wait) vs. asynchronous (not)

30 Concurrency l Synchronous (blocking) –Same “feel” as local procedure case –Thread resources (memory) are idle –Client may be left idle l (other threads with things to do?) l Asynchronous (non-blocking) –Could be unreliable – never collects result –Could be reliable l continue with other operations until the result is returned. l => need some way to “rejoin” results (new API)

31 Making a Remote Procedure Call (cont.) Client Stub Client Comms 2 9 Callee 5 Server Stub 4 7 Server Comms 3 Network Caller Start 10 Finish generic specific

32 Making a remote procedure call (cont.) The Client Stub l The caller’s ancillary operations are gathered into a client stub (1) l The stub makes the required preparations and the passes the data to the processes’ communications function (2) –Marshalls native argument types into byte sequences l The comms. function passes a stream of bytes to the remote process, which is listening for them (3) –Uses standard networking facilities, e.g. TCP or UDP

33 Request message l Contains: –Byte sequence representations of arguments –Byte sequence representation of method/procedure to call –[option] byte sequence representation of server object identity –[option] unique request identifier l To match responses and/or avoid duplicates l Also requires return information and error checking –often part of networking support, e.g. TCP

34 Making a remote procedure call (cont.) The Server Stub l Server comms. function listens for incoming communications (3) –Again using standard networking facilities l Collects the incoming data, derives the procedure being called, and passes the data to the stub for that procedure (4) –Unmarshalls transmitted bytes to native types for arguments l The stub then calls the actual procedure code with the received arguments (5) –Identified by e.g. name in received message

35 Making a remote procedure call (cont.) Results in Server l Procedure call results on the server side are returned to the server stub (6) l The server stub then passes the results to the server comms (7) –Marshalling result l which sends them to the client comms as a byte stream (8). –Standard networking

36 Response message l Contains: –Byte sequence representations of result (if any) l Or byte sequence representation of failure description if unsuccessful –[option] unique request identifier l To match with request and/or avoid duplicates l Also requires error checking –often part of networking support, e.g. TCP

37 Making a remote procedure call (cont.) Results in Client l Client comms function receives the response –Standard networking –Incoming response must be linked with calling thread l E.g. by exclusive connection or explicit request ID –returns the values to the waiting client stub (9) l Unmarshalling result –which returns the value to the calling function (10) which continues executing

38 If something goes wrong… l An error in the server –Could be caught by the server stub (e.g. an exception in the callee code) l An error message returned to the client l Client stub reports this error to the caller –E.g. throws an exception –Could be detected by the client (e.g. a network failure) l Client stub reports this error directly to the caller –E.g. throws an exception

39 Stubless Remote Procedure Calls Dynamic Invocation API Client Comms 2 9 Callee 5 (Reflective?) Generic despatcher 47 Server Comms 3 Network Caller Start 10 Finish generic specific reflective

40 Stubless Remote Procedure Calls l No custom-generated interface-specific stub –No custom-generated marshalling l Stubless client –Caller directly constructs (using API) generic RPC requests, that can be sent to any server l Still needs to know what the server will expect l System may have a way to retrieve this information l Can make generic (universal) clients –E.g. for testing, configuration and management

41 Stubless Remote Procedure Calls l Stubless server –Generic stub translates request to local form and invokes callee code directly l E.g. using language reflection facilities l Less code generation l Requires suitable language support and generic marshalling framework –Or generic stub delivers generic RPC requests to generic callee code l E.g. for generic server that passes requests on to another system, or for testing

42 Distributed Object Systems l Often called “middleware”, or “run-time infrastructure”: –Above the networking and OS, below the application –Provide the “glue” to link objects in different process/on different machines. –May provide additional services and support. l Examples: –Java RMI –CORBA (platform independent standard) –DCOM (Microsoft, Windows-specific) –ANSAware,...

43 Distributed Objects Systems (2) l Like RPCs (as already noted) l Relies on interface definitions –e.g. Corba IDL, Java RMI interface bytecode l Defines what a client can ask –client-middleware interface (method signatures) –Supporting services (e.g. naming) l Defines what a server can do –middleware-server interface –Supporting services (e.g. persistence) l Middleware handles requests in generic, portable form