Lect 5
Lect 5
Lect 5
Communication:
• RPC
• RMI
• Message Oriented Middleware
• Streams
function_name (&variable_name1,
function_name (variable_name1, &variable_name2, . . . .);
Calling Parameters
variable_name2, . . . .); //in case of object
object.func_name( object);
Primitive type are passed using "call by Objects are implicitly passed using "call by
Default calling
value". reference".
Conventional Procedure Call
Parameter passing in a local
procedure call:
3
Remote Procedure Call (RPC)
Java
Basic RPC Parameter Remote
operation passing Variations Method
Invocation
(RMI)
4
Remote Procedure Call (RPC)
q An RPC is analogous to a function call.
Like a function call, when an RPC is
made, the calling arguments are
passed to the remote procedure and
the caller waits for a response to be
returned from the remote procedure.
The client makes a procedure call that
sends a request to the server and
waits.
6
Basic RPC Operation (2/3)
7
Basic RPC Operation (3/3)
1. Client procedure calls client stub as 6. Server does work and returns
usual. result to the stub.
2. Client stub builds message and 7. Server stub packs it in message
calls local OS. and calls OS.
3. Client’s OS sends message to 8. Server’s OS sends message to
remote OS. client’s OS.
4. Remote OS gives message to 9. Client’s OS gives message to
server stub. client stub.
5. Server stub unpacks parameters 10. Client stub unpacks result and
and calls server. returns to the client.
8
RPC: Parameter Passing (1/2)
q Parameters marshaling is one of the main tasks in
parameter passing. That should be done to prepare
parameters for passing
9
RPC: Parameter Passing (2/2)
RPC parameter passing:
• RPC assumes copy in/copy out semantics: while
procedure is executed, nothing can be assumed about
parameter values.
• RPC assumes all data that is to be operated on is passed
by parameters (not by value). Excludes passing
references to (global) data.
11
Client-to-Server Binding (DCE)
Issues: (1) Client must locate server machine, and (2) locate
the server.
Example: DCE uses a separate daemon for each server
machine.
13
Remote Method Invocation (RMI)
RMI
q RMI just like RPC is used as a mechanism which enable a client to invoke the
procedure or method from the server through establishing communication
between client and server.
q The common difference between RPC and RMI is that RPC only supports
procedural programming whereas RMI supports object-oriented
programming.
Remote Method Invocation (RMI) Basics
Assume client stub and server skeleton are in place
Client
RemoteObj obj = lookup(10.10.10.10:2020)
int result = obj.remoteMethod(var1, var2);
7 1
RemoteObj Stub
Server
RemoteObj Skeleton
result
6
call 4
obj
int remoteMethod(type1, type2) 5
16
Remote Method Invocation Basics
1. Client invokes method at stub
17
RMI Parameter Passing
Object-by-value: A client may also pass a complete object
as parameter value:
• An object has to be marshaled:
– Marshall its state
– Marshall its methods, or give a reference to where an
implementation can be found
18
RMI
v In Java the parameters are passed to methods and returned in the form of
reference. So, RMI uses call by reference for objects passing. But, this is
problematic for an RMI facility, because not all objects can be remote
objects?.
v Not all JVMs are willing to expose any of their objects. So, it must
determine which could be passed as reference and which could not.
v For objects that cannot be passed as reference Java uses process named
serialization where the objects are passed as value.
RPC vs RMI
RPC RMI
Procedural Object-oriented
Programming Type
programming programming
Parameters Ordinary data passed to remote Objects are passed to
structures are procedures remote methods.
Efficiency Low High
Overheads High Less
In-out parameters are
Yes Not necessarily
mandatory
Provision of ease of
High Low
programming
Others: CORBA
• https://corba.org
• Multi-language support (COBOL, Ada, Lisp, Java, Python,
etc.)
• Legacy technology, but still works
22