The RPC abstraction. Procedure calls well-understood mechanism. - Transfer control and data on single computer

Similar documents
CSCI-1680 RPC and Data Representation John Jannotti

CSCI-1680 RPC and Data Representation. Rodrigo Fonseca

Distributed Systems. How do regular procedure calls work in programming languages? Problems with sockets RPC. Regular procedure calls

Distributed Systems 8. Remote Procedure Calls

Operating Systems. 18. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Spring /20/ Paul Krzyzanowski

System Models and Communication

CSCI-1680 RPC and Data Representation. Rodrigo Fonseca

Remote Procedure Call (RPC) and Transparency

RMI: Design & Implementation

Remote Procedure Calls (RPC)

6 Remote Procedure Call (RPC)

NFS Design Goals. Network File System - NFS

Remote Procedure Call Implementations

CHAPTER - 4 REMOTE COMMUNICATION

Lecture 15: Network File Systems

Distributed File Systems: Design Comparisons

CSci Introduction to Distributed Systems. Communication: RPC

Today CSCI Communication. Communication in Distributed Systems. Communication in Distributed Systems. Remote Procedure Calls (RPC)

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Remote Procedure Call. Chord: Node Joins and Leaves. Recall? Socket API

Remote Procedure Call

MODELS OF DISTRIBUTED SYSTEMS

416 Distributed Systems. RPC Day 2 Jan 12, 2018

Lecture 5: Object Interaction: RMI and RPC

Distributed Systems Theory 4. Remote Procedure Call. October 17, 2008

MODELS OF DISTRIBUTED SYSTEMS

User-level file systems

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

CS 417 9/18/17. Paul Krzyzanowski 1. Socket-based communication. Distributed Systems 03. Remote Procedure Calls. Sample SMTP Interaction

Remote Procedure Calls, TLI, STREAMS

Distributed Systems. 03. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Fall 2017

416 Distributed Systems. RPC Day 2 Jan 11, 2017

Remote Invocation. Today. Next time. l Overlay networks and P2P. l Request-reply, RPC, RMI

COMMUNICATION IN DISTRIBUTED SYSTEMS

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

Remote Procedure Calls CS 707

ECE454 Tutorial. June 16, (Material prepared by Evan Jones)

Lecture 06: Distributed Object

Network File System (NFS)

Communication in Distributed Systems

Dr. Robert N. M. Watson

Announcements. P4: Graded Will resolve all Project grading issues this week P5: File Systems

Chapter 3: Client-Server Paradigm and Middleware

Remote Procedure Call. Tom Anderson

CS2141 Software Development using C/C++ C++ Basics

Administrivia. Remote Procedure Calls. Reminder about last time. Building up to today

Remote Invocation. To do. Request-reply, RPC, RMI. q Today q. q Next time: Indirect communication

RPC Paradigm. Lenuta Alboaie Andrei Panu

Structured communication (Remote invocation)

Lecture 12 RPC RPC RPC. Writing an RPC Program. Sun RPC RPC. February 9+11, 2005

Chapter 5: Remote Invocation. Copyright 2015 Prof. Amr El-Kadi

Lecture 19. NFS: Big Picture. File Lookup. File Positioning. Stateful Approach. Version 4. NFS March 4, 2005

Remote Procedure Calls

Thrift specification - Remote Procedure Call

03 Remote invoaction. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

REMOTE PROCEDURE CALLS EE324

Distributed File Systems

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Chapter 11: Implementing File-Systems

Last Class: RPCs. Today:

Middleware. Adapted from Alonso, Casati, Kuno, Machiraju Web Services Springer 2004

Building up to today. Remote Procedure Calls. Reminder about last time. Threads - impl

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

DFS Case Studies, Part 1

Overview. Communication types and role of Middleware Remote Procedure Call (RPC) Message Oriented Communication Multicasting 2/36

Distributed Systems. 5. Remote Method Invocation

How do modules communicate? Enforcing modularity. Modularity: client-server organization. Tradeoffs of enforcing modularity

Interprocess Communication

Category: Informational October 1996

Network file systems. Administrivia. Naming structures. Naming schemes. NFS version 2 [Sandberg] What s a network file system?

Lecture 8: February 17

CSE 358 Spring 2006 Selected Notes Set 8

Chapter 5 Distributed Objects and Remote Invocation

Networks and Operating Systems Chapter 3: Remote Procedure Call (RPC)

Transport Layer. Chapter 3: Transport Layer

Communication. Communication. Distributed Systems. Networks and protocols Sockets Remote Invocation Messages Streams. Fall /10/2001 DoCS

NFS version 3. - Supports clients and servers with different uids/gids

Distributed Systems are Everywhere!" CS162 Operating Systems and Systems Programming Lecture 22 Client-Server" Client-Server" Message Passing"

Distributed file systems

EECS 482 Introduction to Operating Systems

Filesystems Lecture 13

Desarrollo de Aplicaciones en Red. El modelo de comunicación. General concepts. Models of communication. Message Passing

Category: Informational October 1996

OPERATING SYSTEM. Chapter 12: File System Implementation

Overview. Exercise 0: Implementing a Client. Setup and Preparation

Chapter 12 File-System Implementation

Chapter 11: Implementing File Systems

DISTRIBUTED FILE SYSTEMS & NFS

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

RPC and RMI. 2501ICT Nathan

COS 318: Operating Systems. Journaling, NFS and WAFL

Category: Standards Track August RPC: Remote Procedure Call Protocol Specification Version 2

Input And Output of C++

Chapter 12: File System Implementation

Filesystems Lecture 11

Remote Procedure Calls and An Implementation Example. CS587x Lecture 5 Department of Computer Science Iowa State University

Operating Systems Design Exam 3 Review: Spring Paul Krzyzanowski

Remote Invocation. Today. Next time. l Indirect communication. l Request-reply, RPC, RMI

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 22: Remote Procedure Call (RPC)

CS454/654 Midterm Exam Fall 2004

Transcription:

The RPC abstraction Procedure calls well-understood mechanism - Transfer control and data on single computer Goal: Make distributed programming look same - Code libraries provide APIs to access functionality - Have servers export interfaces accessible through local APIs Implement RPC through request-response protocol - Procedure call generates network request to server - Server return generates response

RPC Failure More failure modes than simple procedure calls - Machine failures - Communication failures RPCs can return failure instead of results What are possible outcomes of failure? - Procedure did not execute - Procedure executed once - Procedure executed multiple times - Procedure partially executed Generally desired semantics: at most once

Implementing at most once semantics Danger: Request message lost - Client must retransmit requests when it gets no reply Danger: Reply message may be lost - Client may retransmit previously executed request - Okay if operations are idempotent, but many are not (e.g., process order, charge customer,... ) - Server must keep replay cache to reply to already executed requests Danger: Server takes too long to execute procedure - Client will retransmit request already in progress - Server must recognize duplicate can reply in progress

Server crashes Danger: Server crashes and reply lost - Can make replay cache persistent slow - Can hope reboot takes long enough for all clients to fail Danger: Server crashes during execution - Can log enough to restart partial execution slow and hard - Can hope reboot takes long enough for all clients to fail

Parmeter passing Different data representations - Big/little endian - Size of data types No shared memory - No global variables - How to pass pointers - How to garbage collect distributed objects How to pass unions

Interface Definition Languages Idea: Specify RPC call and return types in IDL Compile interface description with IDL compiler. Output: - Native language types (e.g., C/Java/C++ structs/classes) - Code to marshal (serialize) native types into byte streams - Stub routines on client to forward requests to server Stub routines handle communication details - Helps maintain RPC transparency, but - Still had to bind client to a particular server - Still need to worry about failures

Intro to SUN RPC Simple, no-frills, widely-used RPC standard - Does not emulate pointer passing or distributed objects - Programs and procedures simply referenced by numbers - Client must know server no automatic location - Portmap service maps program #s to TCP/UDP port #s IDL: XDR external Data Representation - Compilers for multiple languages (C, java, C++)

Transport layer Transport layer transmits delimited RPC messages - In theory, RPC is transport-independent - In practice, RPC library must know certain properties (e.g., Is transport connected? Is it reliable?) UDP transport: unconnected, unreliable - Sends one UDP packet for each RPC request/response - Each message has its own destination address - Server needs replay cache TCP transport (simplified): connected, reliable - Each message in stream prefixed by length - RPC library does not retransmit or keep replay cache

Sun XDR External Data Representation - Describes argument and result types: struct message { int opcode; opaque cookie[8]; string name<255>; }; - Types can be passed across the network Libasync rpcc compiles to C++ - Converts messages to native data structures - Generates marshaling routines (struct byte stream) - Generates info for stub routines

Basic data types int var 32-bit signed integer - wire rep: big endian (0x11223344 0x11, 0x22, 0x33, 0x44) - rpcc rep: int32 t var hyper var 64-bit signed integer - wire rep: big endian - rpcc rep: int64 t var unsigned int var, unsigned hyper var - wire rep: same as signed - rpcc rep: u int32 t var, u int64 t var

void No data - wire rep: 0 bytes of data More basic types enum {name = constant,... } enumeration - wire rep: Same as int - rpcc rep: enum bool var boolean - both reps: As if enum bool {FALSE = 0, TRUE = 1} var

Opaque data opaque var[n] n bytes of opaque data - wire rep: n bytes of data, 0-padded to multiple of 4 opaque v[5] v[0], v[1], v[2], v[3], v[4], 0, 0, 0 - rpcc rep: rpc opaque<n> var - var[i]: char & ith byte - var.size (): size t number of bytes (i.e. n) - var.base (): char * address of first byte - var.lim (): char * one past last

Variable length opaque data opaque var<n> 0 n bytes of opaque data - wire rep: 4-byte data size in big endian format, followed by n bytes of data, 0-padded to multiple of 4 - rpcc rep: rpc bytes<n> var - var.setsize (size t n) set size to n (destructive) - var[i]: char & ith byte - var.size (): size t number of bytes - var.base (): char * address of first byte - var.lim (): char * one past last opaque var<> arbitrary length opaque data - wire rep: same - rpcc rep: rpc bytes<rpc INFINITY> var

Strings string var<n> string of up to n bytes - wire rep: just like opaque var<n> - rpcc rep: rpc str<n> behaves like str, except cannot be NULL, cannot be longer than n bytes string var<> arbitrary length string - wire rep: same as string var<n> - rpcc rep: same as string var<rpc INFINITY> Note: Strings cannot contain 0-valued bytes - Should be allowed by RFC - Because of C string implementations, does not work - rpcc preserves broken semantics of C applications

Arrays obj t var[n] Array of n obj ts - wire rep: n wire reps of obj t in a row - rpcc rep: array<obj t, n> var; as for opaque: var[i], var.size (), var.base (), var.lim () obj t var<n> 0 n obj ts - wire rep: array size in big endian, followed by that many wire reps of obj t - rpcc rep: rpc vec<obj t, n> var; var.setsize (n), var[i], var.size (), var.base (), var.lim ()

Pointers obj t *var optional obj t - wire rep: same as obj t var<1>: Either just 0, or 1 followed by wire rep of obj t - rpcc rep: rpc ptr<obj t> var - var.alloc () makes var behave like obj t * - var.clear () makes var behave like NULL - var = var2 Makes a copy of *var2 if non-null Pointers allow linked lists: struct entry { filename name; entry *nextentry; }; Not to be confused with network object pointers!

struct type { type_a fielda; type_b fieldb;... }; Structures wire rep: wire representation of each field in order rpcc rep: structure as defined

Discriminated unions union type switch (simple_type which) { case value_a: type_a vara;... default: void; }; simple type must be [unsigned] int, bool, or enum Wire representation: wire rep of which, followed by wire rep of case selected by which.

Discriminated unions: rpcc representation struct type { simple_type which; union { union_entry<type_a> vara;... }; }; void type::set which (simple type newwhich) sets the value of the discriminant vara behaves like type A * if which == value A Otherwise, accessing vara causes core dump (when using dmalloc)

struct fadd_arg { string var<>; int inc; }; Example: fetch and add server union fadd_res switch (int error) { case 0: int sum; default: void; };

RPC program definition program FADD_PROG { version FADD_VERS { void FADDPROC_NULL (void) = 0; fadd_res FADDPROC_FADD (fadd_arg) = 1; } = 1; } = 300001;

fadd_arg arg; fadd_res res; Client code void getres (clnt_stat err) { if (err) warn << "server: " << err << "\n"; // pretty-prints else if (res.error) warn << "error #" << res.error << "\n"; else warn << "sum is " << *res.sum << "\n"; } void start () { int fd; /*... connect fd to server, fill in arg... */ ref<axprt> x = axprt_stream::alloc (fd); ref<aclnt> c = aclnt::alloc (x, fadd_prog_1); c->call (FADDPROC_FADD, &arg, &res, wrap (getres)); }

Server code qhash<str, int> table; void dofadd (fadd_arg *arg, fad_res *res) { int *valp = table[arg->var]; if (valp) { res.set_error (0); *res->sum = *valp += arg->inc; } else res.set_error (NOTFOUND); } ptr<asrv> s; void getnewclient (int fd) { s = asrv::alloc (axprt_stream::alloc (fd), fadd_prog_1, wrap (dispatch)); }

Server dispatch code void dispatch (svccb *sbp) { if (!sbp) { s = NULL; return; } switch (sbp->proc ()) { case FADDPROC_NULL: sbp->reply (NULL); break; case FADDPROC_FADD: fadd_res res; dofadd (sbp->template getarg<fadd_arg> (), &res); sbp->reply (&res); break; default: sbp->reject (PROC_UNAVAIL); } }

Background: ND NFS version 2 - What is ND? - How is NFS different from ND? - Why might NFS be slower than ND? Some Goals of NFS - Maintain Unix semantics - Crash recovery - Competitive performance with ND Did they achieve goals?

Stateless operation Goal: server crash recovery Requests are self-contained Requests are idempotent - Unreliable UDP transport - Client retransmits requests until it gets a reply - Writes must be stable before server returns - Does this really work?

Semantics Component-by-component lookup Hard/soft mount Credentials and authentication Unlinking open files Permissions on open files Cache consistency

Optimizations NFS server and block I/O daemons Client-side buffer cache (write-behind w. flush-on-close) XDR directly to/from mbufs Client-side attribute cache Fill-on-demand clustering, swap in small programs Name cache