CSE 486/586 Distributed Systems Remote Procedure Call Recap

CSE 486/586 Distributed Systems Remote Procedure Call Recap

Recap: Finger Table • Finding a <key, value> using fingers CSE 486/586 Distributed Systems Remote Procedure Call N20" N102" 86 + 24! Steve Ko Computer Sciences and Engineering University at Buffalo N86" 20 + 26! CSE 486/586, Spring 2013 CSE 486/586, Spring 2013 2 Chord: Node Joins and Leaves Recall? •! When a node joins –! Node does a lookup on its own id –! And learns the node responsible for that id App –! This node becomes the new node’s successor –! And the node can learn that node’s predecessor (which will become the new node’s predecessor) Socket API •! Monitor –! If doesn’t respond for some time, find new TCP UDP OS •! Leave IP –! Clean (planned) leave: notify the neighbors –! Unclean leave (failure): need an extra mechanism to handle Device Drivers lost (key, value) pairs Network Interface CSE 486/586, Spring 2013 3 CSE 486/586, Spring 2013 4 Socket API What’s Wrong with Socket API? Server •! Low-level read/write socket() •! Communication oriented •! Same sequence of calls, repeated many times bind() •! Etc, etc… Client listen() •! Not programmer friendly socket() establish accept() connection connect() block send request write() read() process request send response write() read() CSE 486/586, Spring 2013 5 CSE 486/586, Spring 2013 6 C 1 Another Abstraction RPC •! RPC (Remote Procedure Call) •! Client •! Server –! Goal: it should appear that the programmer is calling a local function int main (…) … –! Mechanism to enable function calls between different { processes –! First proposed in the 80’s … void rpc_call(…) { •! Examples rpc_call(…); … –! Sun RPC … } –! Java RMI –! CORBA } •! Other examples that borrow the idea … –! XML-RPC –! Android Bound Services with AIDL –! Google Protocol Buffers CSE 486/586, Spring 2013 7 CSE 486/586, Spring 2013 8 Local Procedure Call Remote Procedure Call •! E.g., x = local_call(“str”); •! Give an illusion of doing a local call by using •! The compiler generates code to transfer necessary whatever the OS gives things to local_call •! Closer to the programmers –! Push the parameters to the stack –! Language-level construct, not OS-level support –! Call local_call •! What are some of the challenges? •! The compiler also generates code to execute the –! How do you know that there are remote calls available? local call. –! How do you pass the parameters? –! Assigns registers –! How do you find the correct server process? –! Adjust stack pointers –! How do you get the return value? –! Saves the return value –! Calls the return instruction CSE 486/586, Spring 2013 9 CSE 486/586, Spring 2013 10 Stub, Marshalling, & Unmarshalling RPC Process •! Stub functions: local interface to make it appear that the call is local. Client Process Server Process •! Marshalling: the act of taking a collection of data items (platform dependent) and assembling them into the external data representation (platform Client Function Server Function independent). •! Unmarshalling: the process of disassembling data that is in external data representation form, into a Client Stub Server Stub locally interpretable form. Marshalling/unmarshalling Socket API Socket API CSE 486/586, Spring 2013 11 CSE 486/586, Spring 2013 12 C 2 CSE 486/586 Administrivia How Do You Generate Stubs? •! PA2 due in ~2 weeks •! Ever heard of C/C++, Java, Python syntax for RPC? •! PA1 grades are out. –! None! •! AWS codes are on UBLearns. •! Language compilers don’t generate client and server –! Setup instructions have been posted as well. stubs. •! Practice problem set 1 & midterm example posted on •! Common solution: use a separate language and a the course website. pre-compiler •! Midterm on Wednesday (3/6) @ 3pm –! Not Friday (3/8) •! Come talk to me! CSE 486/586, Spring 2013 13 CSE 486/586, Spring 2013 14 Interface Definition Language (IDL) Example: SUN XDR const MAX = 1000; •! Allow programmers to express remote procedures, struct readargs { typedef int FileIdentifier; e.g., names, parameters, and return values. FileIdentifier f; typedef int FilePointer; •! Pre-compilers take this and generate stubs, FilePointer position; typedef int Length; marshalling/unmarshalling mechanisms. Length length; • Similar to writing function definitions struct Data { ! }; int length; char buffer[MAX]; program FILEREADWRITE { }; version VERSION { struct writeargs { void WRITE(writeargs)=1; FileIdentifier f; Data READ(readargs)=2; FilePointer position; }=2; Data data; } = 9999; 16 CSE 486/586, Spring 2013 15 }; CSE 486/586, Spring 2013 How Do You Find the Server Stub Generation Process? •! Solution 1 Compiler / Linker gcc –! Central DB (the first solution proposed) Server •! Solution 2 .o, .exe Program Server .c Server .c –! Local DB with a well-known port (SUN RPC) Stub Source .h Interface ! Common RPC! Stub RPC! Specification! Generator Header LIBRARYLIBRARY! ! e.g., in SUN XDR e.g., rpcgen Client Client .c Client .c Stub Source .o, .exe Program Compiler / Linker gcc CSE 486/586, Spring 2013 17 CSE 486/586, Spring 2013 18 C 3 Local DB with Well-Known Port How to Pass Parameters? Finding An RPC: • Pass by value: no problem CLIENT – Just copy the value Client RPCs live on specific hosts at specific ports. Client Stub • What about pointers/references? Port mapper on the host maps Program – Need to copy the actual data as well Network from RPC name to port# Code – Marshall them at the client and unmarshall them at the When a server process is server initialized, it registers its RPCs – Pass the local pointers/references (handle) with the port mapper on the server • What about complex data structures? struct, class, SERVER A client first connects to port etc. Port Mapper mapper (daemon on standard – Need to have a platform independent way of representing port) to get this handle data Server The call to RPC is then made Server procedure by connecting to the corresponding port Stub CSE 486/586, Spring 2013 19 CSE 486/586, Spring 2013 20 External Data Representation Example: Google Protocol Buffers • Communication between two heterogeneous • Goal: language- and platform-neutral way to specify machines and serialize data – Different byte ordering (big-endian & little-endian) • Provides syntax & pre-compiler (open-source) – Different sizes of integers and other types – Pre-compiler generates code to manipulate objects for a – Different floating point representations specific language, e.g, C++, Java, Python. – Different character sets – The runtime support applies a fast & sloppy compression – Alignment requirements algorithm. • Used in general contexts, not just in RPCs message Book { required string title = 1; repeated string author = 2; optional BookStats statistics = 3; message BookStats { required int32 sales =1; } } CSE 486/586, Spring 2013 21 CSE 486/586, Spring 2013 22 What About Failures? Failure Modes of RPC • Local calls do not fail. Request! • Remote calls might fail. lost Execute correct request" • Programmers should deal with this. function" – No transparency here Reply! Request! Channel Execute fails during Execute, crash reply ! before Reply! Crash reply ! Request! Client machine Execute fails crash before Crash before Reply! receiving execution! reply ! CSE 486/586, Spring 2013 23 CSE 486/586, Spring 2013 24 C 4 Invocation Semantics Invocation Semantics •! Local procedure call: exactly-once •! Remote procedure call: –! 0 times: server crashed or server process died before Fault tolerance measures Invocation executing server code semantics –! 1 time: everything worked well, as expected –! 1 or more: excess latency or lost reply from server and client Retransmit request Duplicate Re-execute procedure retransmission message filtering or retransmit reply •! When do these make sense? No Not applicable Not applicable Maybe –! Idempotent functions: OK to run any number of times Yes No Re-execute procedure At-least-once –! Non-idempotent functions: cannot do it •! What we can offer Yes Yes Retransmit old reply At-most-once –! At least once –! At most once CSE 486/586, Spring 2013 25 CSE 486/586, Spring 2013 26 Remote Method Invocation (RMI) Summary •! RPC enables programmers to call functions in Process P1 (“client”)" Process P2 (“server”)" remote processes. •! IDL (Interface Definition Language) allows programmers to define remote procedure calls. client server remote skeleton object A proxy for B object B •! Stubs are used to make it appear that the call is Request & dispatcher for B's class local. •! Semantics Reply –! Cannot provide exactly once –! At least once Remote Communication Communication Remote reference –! At most once module reference module module module –! Depends on the application requirements CSE 486/586, Spring 2013 27 CSE 486/586, Spring 2013 28 Acknowledgements •! These slides contain material developed and copyrighted by Indranil Gupta (UIUC). CSE 486/586, Spring 2013 29 C 5 .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us