remote procedure call n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Remote Procedure Call PowerPoint Presentation
Download Presentation
Remote Procedure Call

Loading in 2 Seconds...

play fullscreen
1 / 20

Remote Procedure Call - PowerPoint PPT Presentation


  • 161 Views
  • Uploaded on

Remote Procedure Call. Andrew Whitaker CSE451. getPrice. Remote Procedure Call. RPC exposes a programming interface across machines:. interface PriceService { float getPrice(ASIN uniqueID); }. Caller. PriceImpl. RPC System. RPC System. Client. Server. 461 in two slides.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Remote Procedure Call' - astro


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
remote procedure call

Remote Procedure Call

Andrew Whitaker

CSE451

remote procedure call1

getPrice

Remote Procedure Call
  • RPC exposes a programming interface across machines:

interface PriceService {

float getPrice(ASIN uniqueID);

}

Caller

PriceImpl

RPC

System

RPC

System

Client

Server

461 in two slides
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)

what tcp does not provide
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
what uses rpc
What Uses RPC?
  • 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
rpc at 10 000 feet
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
rpc visualized
RPC Visualized

interface PriceService {

float getPrice(ASIN uniqueID);

}

RPC

Compiler

Caller

PriceImpl

Client

Stub

Server

Stub

Client

Server

rpc stubs
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
rpc example an add service
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;

}

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:

send message to server;

receive response;

RPC runtime system:

receive message m;

response = Add_Stub(m);

send response to client;

idl example 1 java rmi
IDL Example #1: Java RMI
  • Interface definition language is Java itself

interface PriceServices extends Remote {

Price getPrice(ASIN uniqueID) throws RemoteException;

}

idl example 2 corba idl

Note: compound types

must be explicitly defined

IDL Example #2: CORBA IDL

module BankSimple{

struct CustomerDetails {

string name;

short age;

};

interface Bank {

CustomerDetails getCustomerDetails (in string name);

};

};

idl example 3 wsdl
IDL Example #3: WSDL????

<?xml version="1.0"?>

<!-- root element wsdl:definitions defines set of related services -->

<definitions name="StockQuote"

targetNamespace="http://example.com/stockquote.wsdl"

xmlns:tns=http://example.com/stockquote.wsdl

xmlns:xsd1=http://example.com/stockquote.xsd

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

<!-- wsdl:types encapsulates schema definitions of communication types; here using xsd -->

<wsdl:types> <!-- all type declarations are in a chunk of xsd -->

<xsd:schema targetNamespace=http://example.com/stockquote.xsd

xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">

<!-- xsd definition: TradePriceRequest [... tickerSymbol string ...] -->

<xsd:element name="TradePriceRequest">

<xsd:complexType>

<xsd:all>

<xsd:element name="tickerSymbol" type="string"/>

</xsd:all> </xsd:complexType> </xsd:element>

<!-- xsd definition: TradePrice [... price float ...] --> <xsd:element name="TradePrice">

xsd:<complexType> <xsd:all> <xsd:element name="price" type="float"/>

</xsd:all> </xsd:complexType> </xsd:element>

</xsd:schema> </wsdl:types>

<!-- request GetLastTradePriceInput is of type TradePriceRequest -->

<wsdl:message name="GetLastTradePriceInput">

<wsdl:part name="body" element="xsd1:TradePriceRequest"/> </wsdl:message>

<!-- request GetLastTradePriceOutput is of type TradePrice -->

<wsdl:message name="GetLastTradePriceOutput">

<wsdl:part name="body" element="xsd1:TradePrice"/>

design issues in rpc
Design Issues in RPC
  • Transparency: to be or not to be?
  • Marshalling and unmarshalling
    • Converting types to byte streams
  • Discovery and naming
  • Versioning
transparency
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
a java rmi example

This doesn’t work! Java RMI is call-by-value

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;

}

revised java rmi example
Revised Java RMI Example

interface FileStream extends Remote {

// read from a (possibly) remote file into a buffer

byte[] read (int howManyBytes)

throws RemoteException;

}

data marshalling
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?
complex types
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
java serialization
Java Serialization
  • Instances of Serializable can automatically converted into a byte stream
    • Thus, RMI allows serializable arguments

public class Person implements Serializable {

private int age;

private String name;

private float salary;

private transient boolean gender;

}

transient turns off serialization

discovery and lookup
Discovery and Lookup
  • Clients must locate a remote object or service