rpc failure
play

RPC / failure 1 last time redo logging (fjnish) (weird?) choice - PowerPoint PPT Presentation

RPC / failure 1 last time redo logging (fjnish) (weird?) choice not to use redo logging for everything reasons to use distributed systems mailbox and connnection models names versus addresses domain name system distributed, hierarchical


  1. RPC / failure 1

  2. last time redo logging (fjnish) (weird?) choice not to use redo logging for everything reasons to use distributed systems mailbox and connnection models names versus addresses domain name system — distributed, hierarchical database port numbers sockets: connections as fjle descriptors bind: set local address accept: get connection (as new fjle descriptor) connect: make current fjle descriptor connection to server 2 client/server → peer-to-peer

  3. client/server fmow (multiple connections) bind to host:port close connection socket write response to connection socket read request from connection socket (get connection socket) accept a new connection start listening for connections create server socket spawn new process (fork) close socket read response write request (gets assigned local host:port) connect socket to server hostname:port create client socket or thread per connection 3

  4. sockets: missing pieces translating names to IP address + port number — getaddrinfo construct arguments for bind (set local address) + connect (set remote address) handles using DNS and both IPv4 and IPv6 4

  5. local/Unix domain sockets POSIX defjnes sockets that only work on local machine example use: apps talking to display manager program want to display window? connect to special socket fjle probably don’t want this to happen from remote machines equivalent of name+port: socket fjle appears as a special fjle on disk we will use this in assignment but you won’t directly write code that uses POSIX API 5

  6. Unix-domain sockets: client example struct sockaddr_un server_addr; server_addr.sun_family = AF_UNIX; int fd = socket(AF_UNIX, SOCK_STREAM, 0); if (connect(fd, &server_addr, sizeof (server_addr)) < 0) handleError(); ... // use 'fd' here 6 strcpy(server_addr.sun_path, "/path/to/server.socket");

  7. Unix-domain sockets: client example struct sockaddr_un server_addr; server_addr.sun_family = AF_UNIX; strcpy(server_addr.sun_path, "/path/to/server.socket"); int fd = socket(AF_UNIX, SOCK_STREAM, 0); if (connect(fd, &server_addr, sizeof (server_addr)) < 0) handleError(); ... // use 'fd' here 6

  8. Unix-domain sockets on my laptop LISTENING 2 unix / run / user /1000/ keyring / control 37874 LISTENING STREAM [ ACC ] 2 unix / run / user /1000/ gnupg / S . gpg agent . ssh 37871 STREAM STREAM [ ACC ] 2 unix 60556115 / var / run / cups / cups . sock LISTENING STREAM [ ACC ] 2 unix / run / user /1000/ gnupg / S . gpg agent . extra 37870 LISTENING [ ACC ] LISTENING [ ACC ] 2 . . . 60557382 / run / cups / cups . sock LISTENING STREAM [ ACC ] 2 unix 32980 LISTENING STREAM [ ACC ] unix 49772163 / run / user /1000/ pulse / cli 59062776 / run / user /1000/ speech dispatcher / speechd . sock LISTENING STREAM [ ACC ] 2 unix 49772158 / run / user /1000/ pulse / native LISTENING STREAM [ ACC ] 2 unix STREAM 2 unix unix LISTENING STREAM [ ACC ] 2 unix / run / udev / control 844 LISTENING SEQPACKET [ ACC ] 2 / run / user /1000/ systemd / notify unix 40077 DGRAM ] [ 2 unix Path State Type Proto RefCnt Flags Active UNIX domain sockets ( servers and established ) 40080 / run / user /1000/ systemd / private 2 2 / run / user /1000/ gnupg / S . gpg agent . browser 37869 LISTENING STREAM [ ACC ] 2 unix / run / user /1000/ bus 37868 LISTENING STREAM [ ACC ] [ ACC ] unix / run / user /1000/ gnupg / S . dirmngr STREAM LISTENING 40084 / run / user /1000/ gnupg / S . gpg agent 7 unix 2 [ ACC ] STREAM LISTENING 37867 cr4bd@reiss − lenovo :~ $ netstat −− unix − a I − Node @ / tmp /. X11 − unix / X0

  9. remote procedure calls goal: I write a bunch of functions can call them from another machine some tool + library handles all the details called remote procedure calls (RPCs) 8

  10. transparency common hope of distributed systems is transparency transparent = can “see through” system being distributed for RPC: no difgerence between remote/local calls (a nice goal, but…we’ll see) 9

  11. stubs typical RPC implementation: generates stubs stubs = wrapper functions that stand in for other machine calling remote procedure? call the stub same prototype are remote procedure implementing remote procedure? a stub function calls you 10

  12. typical RPC data fmow network return value (or failure indication) its arguments converted to bytes idenitifjer for function being called + (and return value to bytes) converts bytes to arguments contains actual function call generated by compiler-like tool (and bytes to return value) convert arguments to bytes contains wrapper function generated by compiler-like tool (using sockets) function call Machine B (RPC server) return value return value function call program server server stub RPC library RPC library client stub program client Machine A (RPC client) 11

  13. typical RPC data fmow network return value (or failure indication) its arguments converted to bytes idenitifjer for function being called + (and return value to bytes) converts bytes to arguments contains actual function call generated by compiler-like tool (and bytes to return value) convert arguments to bytes contains wrapper function generated by compiler-like tool (using sockets) function call Machine B (RPC server) return value return value function call program server server stub RPC library RPC library client stub program client Machine A (RPC client) 11

  14. typical RPC data fmow network return value (or failure indication) its arguments converted to bytes idenitifjer for function being called + (and return value to bytes) converts bytes to arguments contains actual function call generated by compiler-like tool (and bytes to return value) convert arguments to bytes contains wrapper function generated by compiler-like tool (using sockets) function call Machine B (RPC server) return value return value function call program server server stub RPC library RPC library client stub program client Machine A (RPC client) 11

  15. typical RPC data fmow network return value (or failure indication) its arguments converted to bytes idenitifjer for function being called + (and return value to bytes) converts bytes to arguments contains actual function call generated by compiler-like tool (and bytes to return value) convert arguments to bytes contains wrapper function generated by compiler-like tool (using sockets) function call Machine B (RPC server) return value return value function call program server server stub RPC library RPC library client stub program client Machine A (RPC client) 11

  16. typical RPC data fmow network return value (or failure indication) its arguments converted to bytes idenitifjer for function being called + (and return value to bytes) converts bytes to arguments contains actual function call generated by compiler-like tool (and bytes to return value) convert arguments to bytes contains wrapper function generated by compiler-like tool (using sockets) function call Machine B (RPC server) return value return value function call program server server stub RPC library RPC library client stub program client Machine A (RPC client) 11

  17. gRPC code preview server subclass overrides methods to provide remote calls stub and context to pass info about where the function is actually located (on client) and how it was called (on server) gRPC requires exactly one arguments object to simplify library/cross-language compatability some other RPC systems are more fmexible generated code (“server stub”) defjnes base class so it’s easy for library to fjnd them {}". format (err)) client: calls “MakeDirectory” function on server local-only code would have been: MakeDirectory(path="/directory/name") server: defjnes “MakeDirectory” function local-only code would have been: def MakeDirectory(path): ... return Empty() 12 client: ... stub = ... try : stub.MakeDirectory(MakeDirectoryArgs(path="/directory/name")) except : # handle error server: class DirectoriesImpl(DirectoriesServicer): def MakeDirectory(self, request, context): error: try : os.mkdir(request.path) except OSError as e: context.abort(grpc.StatusCode.UNKNOWN, "OS returned ␣ ␣ ␣

  18. gRPC code preview server subclass overrides methods to provide remote calls stub and context to pass info about where the function is actually located (on client) and how it was called (on server) gRPC requires exactly one arguments object to simplify library/cross-language compatability some other RPC systems are more fmexible generated code (“server stub”) defjnes base class so it’s easy for library to fjnd them {}". format (err)) client: calls “MakeDirectory” function on server local-only code would have been: MakeDirectory(path="/directory/name") server: defjnes “MakeDirectory” function local-only code would have been: def MakeDirectory(path): ... return Empty() 13 client: ... stub = ... try : stub.MakeDirectory(MakeDirectoryArgs(path="/directory/name")) except : # handle error server: class DirectoriesImpl(DirectoriesServicer): def MakeDirectory(self, request, context): error: try : os.mkdir(request.path) except OSError as e: context.abort(grpc.StatusCode.UNKNOWN, "OS returned ␣ ␣ ␣

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend