03 - Remote Invoaction: Request-Reply RPC RMI Coulouris 5 Birrel - Nelson - 84 PDF
03 - Remote Invoaction: Request-Reply RPC RMI Coulouris 5 Birrel - Nelson - 84 PDF
● Request-reply ● Coulouris 5
● RPC ● Birrel_Nelson_84.pdf
● RMI
2/22
Remote invocation
● Mechanisms for process communication on a DS
● Built on top of interprocess communication
primitives
– Lower level
– Provided by the OS
Applications
Client Server
Request
doOperation getRequest
message
select object
(wait) execute method
Reply sendReply
message
(continuation)
5/22
Request Reply Protocols
● doOperation
– Sends request to the remote server
– Arguments
● Server remote reference
● Operation id
● Arguments
– Returns
● reply
– send (TCP), sendto (UDP)
6/22
Request Reply Protocols
● getRequest
– Blocking function / waits for request
– Returns request data
● sendReply
– Sends response to client
– Arguments
● Reply
● Client id
– send (TCP), sendto (UDP)
7/22
Request Reply Protocols
MessageType int (0=Request, 1= Reply)
requestId int
remoteReference RemoteRef
operationID int or Operation
arguments array of bytes
● Message identifier
– RequestId
● increasing sequence of integers (per sending process)
– RemoteReference
● Identification of the process (IP address, port, process id)
8/22
Request Reply Protocols
● Failure model (UDP)
– Omission failures
– Delivery order not guaranteed
● Timeouts
– doOperation can
● Repeats transmission of message
9/22
Request Reply Protocols
● Duplicate messages
– After time-outs
– Protocols must recognize them
● Lost reply messages
– Reception of duplicate request
– Ignore second repetitions
– Implement idepotent operation
● History
– required
10/22
Request Reply Protocols
● Exchange protocols ● Exchange protocols
– R (request) – RRA (request-reply-ack)
● Online request is sent ● Explicit ack of the reply
● No need for response ● Server can clean history
● Client may unblock imediatly ● TCP
– RR (request-reply)
● Special ACK message not
– simplifies protocol
required – Larger messages
– Implemented by the response
● Subsequent Request is
– Acknowledgements not
Acknowledgment of the necessary
reply
12/22
Remote Procedure Call
● Request Reply protocols
– Not transparent (w.r.t. distribution)
– Local invocation ≠ remote invocation
● Extends procedure call abstraction
– RPCs are called as if in local address space
– RPC system hides
● Distribution
● Encoding/decoding of parameters/reply
● Passing of messages
● Semantics of call
13/22
Remote Procedure Call
Interfaces
● RPCs should mimic programming language
structures
– Modules/ libraries / classes
– Function/procedures/methods
– Use the concept of interface
● A set of well defined ointeraction points
– Encapsulate implementation details
● Service interfaces
– Set of procedures offered by a server
– Defining parameters and return values (and types)
14/22
Remote Procedure Call
Interfaces
● Provide/implement goof programming practices
– Implementation are hidden from the programmer
– Server programming language /architecture is hidden
– SW evolution is possible
● Distribution imposes
– Impossible access to remote variables
– Call by reference not suitable
● Input parameters: client → server transfer
● Output parameters client ← server transfer
– Addresses in one process are not valid on another
● Addresses can not be passed
15/22
Remote Procedure Call
Interface Definition Languages
● Static languages require the a priori declaration of functions and types
● Publication of a service requires its description
● Interface Definition Languages (IDL) allow:
– Specification of interfaces
– Communication of interfaces
– Production of .c/.h files
● Examples
– SUN XDR, – Java interfaces
– CORBA IDL – Google protocol buffers
– Webservices WSDL
16/22
Remote Procedure Call
RPC call semantics
● DoOperation can be implemented differently
– Retry request message
● Are retries made until reply is received?
– Duplicate filtering
● What happens when server receives duplicate message
– Retransmission of results
● Is history kept to prevent re-execution of operations?
17/22
Remote Procedure Call
RPC call semantics
Fault tolerance measures
Call semantics Retransmit request Re-execute procedure or
Duplicate filtering
message retransmit reply
Maybe No Not Applicable Not Applicable
No fault tolerance measures applied
Omission failures (message lost), crash failures (server fails)
Reply
client stub server stub
procedure procedure
client service
program Communication Communication
module module dispatcher procedure
●
Generated automatically ●
General
– Stubs – Communication module
●
Marshal arguments /return
values
●
Hand coded
– Dispatcher – Client program
●
Redirects call – Service procedure
20/22
Remote Method Invocation
● Extends RPC to the OO world
● RPC and RMI
– Support programming with interfaces
– Built on top of Request-reply protocols
– Offer similar semantics
– Offer similar level of transparency
● RMI
– Use OO mechanisms
● Object, classes inheritance, OO development methods/tools
– Provide concept of object identity
● All objects have references (local or remote)
● That can be globally accessed
21/22
Remote Method Invocation
Object model
Remote object
Remote
● Object references interface Data
m1 m4
– remote
{
Implementation m5
m2 of methods
m3 m6
● Interfaces
– remote
● Actions Local Local remote
remote invocation invocation invocation
– Object creation
– Further invocations
● Exception
– Can be generated and “returned”
● Garbage collection
22/22
Remote Method Invocation
Implementation
● Proxy
● Dispatcher
● Skeleton
● Static Generation
– IDL+compiler (Similar to SUN RPC)
● Dynamic invocation
– Language support for refection
● method interception (client)
● Dynamic code loading
23/22
Remote Method Invocation
Execution
● Server/client programs
● Binder/ns
– Process that provides object reference from textual
name
● Server threads
– In order to allow concurrent method execution
– Requires synchronization
● Activation
– When are objects killed?