150 likes | 252 Views
COMP 150-IDS: Internet Scale Distributed Systems (Fall 2012). A Brief Intro to the RPC Project Framework. Noah Mendelsohn Tufts University Email: noah@cs.tufts.edu Web: http://www.cs.tufts.edu/~noah. Review From the Earlier Lecture On Remote Procedure Call. float sqrt(float n) { send n;
E N D
COMP 150-IDS: Internet Scale Distributed Systems (Fall 2012) A Brief Intro to theRPC Project Framework Noah Mendelsohn Tufts UniversityEmail: noah@cs.tufts.edu Web: http://www.cs.tufts.edu/~noah
floatsqrt(float n) { send n; read s; return s;} invoke sqrt(4) voiddoMsg(Msg m) { s = sqrt(m.s); send s; } Request result=2 (no exception thrown) Response proxy stub RPC: Call remote functions automatically • Interface definition: float sqrt(float n); • Proxies and stubs generated automatically • RPC provides transparent remote invocation floatsqrt(float n) { …compute sqrt… return result;} x = sqrt(4) CPU Memory Storage CPU Memory Storage
Demo program uses function w/no arguments This client int main() { func1()} simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage
Demo program uses function w/no arguments …is calling this function int main() { func1()} voidfunc1() { return;} simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage Interface definition file: simplefunction.idl void func1();
voidvoid() { send func1; read DONE; } simplefunction.proxy.cpp Demo program uses function w/no arguments Sample proxy int main() { func1()} voidfunc1() { return;} simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage simplefunction.cpp
voidvoid() { send func1; read DONE; } simplefunction.proxy.cpp Demo program uses function w/no arguments int main() { func1()} voidfunc1() { return;} simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage simplefunction.cpp Proxy and stub names always match IDL file name
voidvoid() { send func1; read DONE; } simplefunction.proxy.cpp Demo program uses function w/no arguments int main() { func1()} simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage rpcserver is generic main program…doesn’t depend on IDL or func1 int Main() { …loop accepting connections{ while(!eof){ dispatchFunction() } } } rpcserver.cpplinked as simplefunctionserver
voidvoid() { send func1; read DONE; } simplefunction.proxy.cpp Demo program uses function w/no arguments int main() { func1()} simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage …but we name the executable to match the particular use (simplefunctionserver) int Main() { …loop accepting connections{ while(!eof){ dispatchFunction() } } } rpcserver.cpplinked as simplefunctionserver
voidvoid() { send func1; read DONE; } simplefunction.proxy.cpp Demo program uses function w/no arguments All stubs provide a dispatchFunction int main() { func1()} simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage voiddispatchFunction() { read from socket call __func1() } void __func1() { read args from stream call func1 send response } int Main() { …loop accepting connections{ while(!eof){ dispatchFunction() } } } simplefunction.stub.cpp rpcserver.cpplinked as simplefunctionserver
voidvoid() { send func1; read DONE; } simplefunction.proxy.cpp Demo program uses function w/no arguments …that reads function names from the network and calls the right stub int main() { func1()} simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage voiddispatchFunction() { read from socket call __func1() } void __func1() { read args from stream call func1 send response } int Main() { …loop accepting connections{ while(!eof){ dispatchFunction() } } } simplefunction.stub.cpp rpcserver.cpplinked as simplefunctionserver
voidvoid() { send func1; read DONE; } invoke func1() Request DONE Response simplefunction.proxy.cpp Demo program uses function w/no arguments int main() { func1()} voidfunc1() { return;} simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage simplefunction.cpp voiddispatchFunctiong() { read from socket call __func1() } void __func1() { read args from stream call func1 send response } int Main() { …loop accepting connections{ while(!eof){ dispatchFunction() } } } simplefunction.stub.cpp rpcserver.cpplinked as simplefunctionserver
invoke func1() Request DONE Response Demo program uses function w/no arguments Interface definition file:simplefunction.idl int main() { func1()} voidfunc1() { return;} simplefunctionclient.cpp You’ll be implementing proxies and stubs like these…first by hand…then using your RPC generator CPU Memory Storage CPU Memory Storage simplefunction.cpp voidvoid() { send func1; read DONE; } voiddispatchFunctiong() { read from socket call __func1() } void __func1() { read args from stream call func1 send response } int Main() { …loop accepting connections{ while(!eof){ dispatchFunction() } } } simplefunction.proxy.cpp simplefunction.stub.cpp rpcserver.cpplinked as simplefunctionserver
invoke func1() Request DONE Response Demo program uses function w/no arguments Interface definition file:simplefunction.idl int main() { func1()} voidfunc1() { return;} simplefunction.proxy.cpp & simplefunction.stub.cpp are provided for you as samples … Yours will have to support other IDL files with functions that take arguments and return values! simplefunctionclient.cpp CPU Memory Storage CPU Memory Storage simplefunction.cpp voidvoid() { send func1; read DONE; } voiddispatchFunctiong() { read from socket call __func1() } void __func1() { read args from stream call func1 send response } int Main() { …loop accepting connections{ while(!eof){ dispatchFunction() } } } simplefunction.proxy.cpp simplefunction.stub.cpp rpcserver.cpplinked as simplefunctionserver