Download presentation
Presentation is loading. Please wait.
Published byMarsha Ray Modified over 9 years ago
1
Remote Procedure Call Andrew Whitaker CSE451
2
Remote Procedure Call RPC exposes a programming interface across machines: interface PriceService { Price getPrice(ASIN uniqueID); } ClientServer PriceImpl RPC System Caller RPC System getPrice
3
461 in two slides Network software is arranged in layers Higher layers offer more convenient programming abstractions TCP provides in-order, reliable delivery of a byte stream Application (HTTP, FTP) Transport (TCP, UDP) Network (IP) Link (Ethernet, 802.11)
4
What TCP Does (Not) Provide TCP allows one machine to send a reliable byte stream to another machine: Socket.send(byte[] byteBuffer); TCP does not provide: Mapping to/from programming language types Called “marshalling” Thread management Intelligent failure semantics Discovery RCP packages build on TCP (or sometimes UDP) to provide these services
5
What Uses RPC? Service-oriented architectures Web services allow arbitrary clients and servers to communicate using XML-based exchange formats Distributed file systems e.g., NFS (network file system) Multiplayer network games Many other distributed systems
6
RPC at 10,000 feet The key to an RPC system is its Interface Definition Language (IDL) An interface provides the contract between clients and servers Given an interface, an RPC compiler generates RPC “stubs” Which abstract away the network
7
RPC Visualized interface PriceService { Price getPrice(ASIN uniqueID); } ClientServer PriceImpl Server Stub Caller Client Stub RPC Compiler
8
RPC stubs The client program thinks it’s invoking the server But, it’s really calling the client-side stub The server program thinks it’s called by the client But it’s really called by the server-side stub The stubs send messages to each other to make the RPC happen transparently
9
RPC Example: An Add() Service Client Program: … sum = server->Add(3,4); … Server Program: int Add(int x, int y) { return x + y; } client-side stub: int Add(int x, int y) { alloc message buffer; mark as “add” call; store x,y in buffer; send message; receive response; unpack response; return response; } RPC runtime system: send message to server; receive response; server-side stub: Message Add_Stub(Message m) { remove x,y from m; r = Add(x,y); allocate response buffer; store r in response; return response; } RPC runtime system: receive message m; response = Add_Stub(m); send response to client;
10
IDL Example #1: Java RMI Interface definition language is Java itself interface PriceServices extends Remote { Price getPrice(ASIN uniqueID) throws RemoteException; }
11
IDL Example #2: CORBA IDL module BankSimple{ struct CustomerDetails { string name; short age; }; interface Bank { CustomerDetails getCustomerDetails (in string name); }; Note: compound types must be explicitly defined
12
IDL Example #3: WSDL ???? <definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"http://example.com/stockquote.wsdl xmlns:tns=http://example.com/stockquote.wsdlhttp://example.com/stockquote.wsdl xmlns:xsd1=http://example.com/stockquote.xsdhttp://example.com/stockquote.xsd xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> <xsd:schema targetNamespace=http://example.com/stockquote.xsdhttp://example.com/stockquote.xsd xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"> xsd: TradePriceRequest TradePrice
13
Design Issues in RPC Transparency: to be or not to be? Marshalling and unmarshalling Converting types to byte streams Discovery and naming Versioning
14
Transparency General distributed systems issue: does a remote service look identical to a local service Transparency allows programmers to ignore the network But, transparency can impose poor performance and complexity In practice File systems try for transparency RPC systems do not
15
A Java RMI Example interface FileStream extends Remote { // read from a (possibly) remote file into a buffer int read (byte[] buffer, int offset, int howManyBytes) throws RemoteException; } This doesn’t work! Java RMI is call-by-value
16
Revised Java RMI Example interface FileStream extends Remote { // read from a (possibly) remote file into a buffer byte[] read (int howManyBytes) throws RemoteException; }
17
Data Marshalling Marshalling is the task of converting programming language types into a byte stream Unmarshalling is the reverse This is boring, but potentially complex How many bits are in an integer? How are floating point numbers represented? Is the architecture big-endian or little-endian?
18
Complex Types Object-oriented languages allow programmer-defined types Two basic strategies: Push the type definition into the IDL (CORBA) Add implicit support to the language Java Serialization
19
public class Person implements Serializable { private int age; private String name; private float salary; private transient boolean gender; } transient turns off serialization Instances of Serializable can automatically converted into a byte stream Thus, RMI allows serializable arguments
20
Discovery and Lookup Clients must locate a remote object or service
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.