What Is RPC RMI
What Is RPC RMI
What is RPC?
When a process on machine A (or client) calls a procedure on machine B (or server), the calling
process on A is suspended, and execution of the called procedure takes place on B.
Information can be transported from the caller to callee in the parameters and can come back in
the procedure result.
Programmers cannot see message passing at all (transparency). This method is known as Remote
Procedure Call or RPC. RPC is supported by middleware communication services. RPC was
initially implemented using C. Principle of RPC between a client and server
(1) Principle of RPC between a client and server
(2) General structure of RPC
Stub is a small chunk of C code that is compiled and linked into the client and server programs.
Client stub converts parameters into a string of bits and sends the message over the network.
Server stub takes the message, converts it back into parameters, and then calls the server.
Packing parameters into a message is called parameter marshaling.
Steps of a Remote Procedure Call
i. Client procedure calls client stub in normal way
ii. Client stub builds message, calls local OS
iii. Client's OS sends message to remote OS
1
iv. Remote OS gives message to server stub
v. Server stub unpacks parameters, calls server
2
Deferred
Deferred Asyn
It is a combination of two asynchronous RPCs.
Asynchronous RPC is useful when there is a result to be returned from server but client is not
prepared to wait for it and starts doing something else (eg remote computing).
One-Way RPC
Client does not wait for an acknowledgement from server and starts doing something else
immediately after sending the request.
REMOTE METHOD INVOCATION
From Procedures to Objects
Object hides its internals from outside world by means of a well-defined interface, which allows
objects to be easily replaced or adapted whereas the interface remains the same. (partial
modification)
An object encapsulates data (state), and the operations on those data (methods). Methods are
made available through an interface. The state of the object can only be accessed by invoking
methods through the interface. (simple and unique access)
An object may have many interfaces. Likewise, an interface definition may be implemented by
several objects. (multiple implementations)
The separation between interfaces and the objects implementing these interfaces allows an
interface to be placed at one machine, and the object itself to reside on another machine.
(distributed objects)
3
What is RMI?
RMI uses the same principle as RPC.
Distributed objects are implemented using object-oriented programming languages (C++ or
Java), rather than C.
It uses method invocation to perform processes, instead of procedure call. Development of RMI
applications is supported by many distributed object-based middleware, such as CORBA and
DCOM. General structure of RMI Note Important Terminologies
Proxy (client stub) is an implemented interface (on client machine) of a distributed object (on
server machine). It marshals method invocations into messages and unmarshals reply messages
to return the invocated results to the client. The remote object also has the same interface.
Skeleton (server stub) unmarshals incoming invocation requests to proper method invocations at
the object’s interface. It also marshals and forwards reply message to client proxy.
RMI operation: Steps in Making RMI (one-way)
i. Client invokes a method through the interface (handled by client Proxy) that is as same as that
of the (remote) object.
ii. Client Proxy (stub) marshals the invocation into messages and then passes it to the server
through network.
iii. Skeleton (server stub) unmarshals incoming message back to invocation and then passes it to
the object through the object’s interface.
4
iv. The object processes the incoming invocation by calling the right method to work on the
input data.
COMMUNICATION SYSTEMS
Problems with RPCs and RMIs
For RPC and RMI, we always assume the server side is executing at the time a client request is
issued. The interprocess will not happen if the server side is down. In any cases, after a request
is issued, the client side will be blocked until the result or an acknowledgement from the server
side is received. It is not efficient!