RMI Chapter 5 Nematulllah and Fariba

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 26

‫بسم هللا الرحمن الرحیم‬

CHAPTER(5)

Remote Method Invocation (RMI)


OUTLIN
• Request-reply protocols
E
• Remote procedural call (RPC)
• Introduction RPC
• Element of RPC
• RPC Execution
• RPC Implementation
• Remote Method Invocation (RMI)
• Architecture of RMI
• Layer of RMI
• Marshalling and Demarshalling
• Stub and skeleton
• How RMI contact Remote
• RMI Advantages & Disadvantages
• Distributed Garbage Collection
REQUEST-REPLY PROTOCOLS

• This protocol designed which represent message passing according to


two-way exchange
• This request-reply protocol matches requests to replies. It may be designed
to provide certain delivery guarantees If UDP datagrams are used, the delivery guarantees
must be provided by the request-reply protocol, which may use the server reply message
as an acknowledgement of the client request message
• The protocol we describe here is based on a trio of communication primitives
• do Operation, get Request and send Reply
REQUEST-REPLY COMMUNICATION
REMOTE PROCEDURAL
CALL

• RPC is a inter process communication which allows calling a function in another process
residing in local or remote machine, it invoke a function

• RPC is a protocol that one program can use to request a service from a program located in
another computer on a network without having to understand the network details. A
procedural call is also known as a

function call
BASIC RPC OPERATION
RPC OPERATION
ELEMENTS OF RPC MECHANISM
IMPLEMENTATION

• Client

• Client Stub

• RPC runtime

• Server stub

• Server
RPC
EXECUTION
CONT…
• Client procedural calls client stub in normal way
• Client stub builds message ,calls local
• Client ‘s OS sends message to remote OS
• Remote OS gives message to server stub
• Server stub unpacks parameters, calls server
• Server does work, returns result to the stub
• Server stub packs it in message, calls local OS
• Server ‘s OS send message to client’s OS
• Server ‘s OS gives message to client stub
• Stub un packs result ,return to client
RPC IMPLEMENTATION
RPC CALL/REQUEST
MESSAGE
RPC REPLY MESSAGE
WHAT IS RMI ?

RMI stands for Remote Method Invocation. 


• To interact with the methods of objects in other / remote machines using JVM, RMI is
used. 
• It is an approach where a method on a remote machine invokes another method on another
machine to perform some computation and return the result to the calling method
ARCHITECTU
RE
THERE ARE 4 LAYER IN
RMI

1) Application layer

2) Proxy layer

3) Remote Reference layer

4) Transport layer
CONT…
Application layer :
• Responsible for running client an applications here client application invoke
methods defined server application
• When client invokes a method then request is passed to proxy

Proxy layer :
• Responsible for creating client stub at side by packing the request msgs sent by client
process
• Also responsible for creating skeleton by packing response msgs sent by server
• Once stub and skeleton are created they are passed to RRL
CONT…
Remote Reference layer (RRL)
• Checks semantic and remote reference used by client process using remote reference
protocol
• Finally RRL transmits msgs and data to RMI transport layer

Transport Layer :
• Responsible for establishing and maintaining stream oriented connection between client and
server
• Also responsible for managing send/receive of request/reply msgs between client and server
MARSHALLING AND UNMARSHALING:

• During communication between two machines through RPC or RMI, parameters are packed
into a message and then sent over the network. This packing of parameters into a message is
called marshalling. On the other side these packed parameters are unpacked from the
message which is called unmarshalling.
WHAT IS STUB AND SKELETON???

• Server side stub is referred to as a skeleton.


• The role of the stubs is to marshal and unmarshal the messages that are sent and received on
the client or the server side
THE STUB/SKELETON
LAYER
• The stub/skeleton layer sits in between application layer and the rest of the RMI system and
acts as an interface. 
• This layer transmits the information to remote layer. This transmission is done through the
marshalling of streams. 
• These streams performs the object serialization.
• A stub is a remote object at the client-side. This stub implements all the interfaces which
remote object implementation supports.
• A skeleton is a remote object at the server-side. This stub consists of methods that invokes
dispatch calls to the remote implementation of objects.
HOW RMI CLIENTS CONTACT REMOTE RMI
SERVERS:
• The client procedure calls the client stub in the normal way.
• The client stub builds a message and traps to the kernel.
• The kernel sends the message to the remote kernel.
• The remote kernel gives the message to the server stub 
• The server stub unpacks the parameters and calls the server.
• The server does the work and returns the result to the stub.
• The server stub packs it in a message and traps to the kernel.
• The remote kernel sends the message to the clients kernel.
• The clients kernel gives the message to the client stub.
• The stub unpacks the result and returns to the client.
ADVANTAGE AND DISADVANTAGE OF RMI.

• RMI Advantages:
 Java RMI model is simple and easy to use.
 Very reliable distributed applications.
 Easier to use and setup than CORBA.
 RDMI enables dynamic invocation.
• RMI disadvantages:
 java only.
 Limited functionality because of security restrictions.
 No support for legacy systems.
DISTRIBUTED GARBAGE
COLLECTION
• RMI provides a distributed garbage collector that deletes remote objects no longer
referenced by a client
• Uses a reference-counting algorithm to keep track of live references in each Virtual Machine
• RMI keeps track of VM identifiers, so objects are collected when no local or remote
references to them
on
e n ti
A tt
ic e
r N
y ou
o r
s F
k
h an
T

You might also like