Google search

Basic and advanced computer skills like Excel with macros, How to speed up your PC, C, CPP, Java programming, HTML, JavaScript, PHP, Wordpress, all web tools, Android tutorials, MySQL Tutorials, WAMP server installation. etc.

Java RMI

RMI : Remote Method Invocation 
Why distributed object system.?
Large problems can be solved easily if they are split among two or more people. Distributed computing helps to solve large problems by splitting them. The split components are kept in different computers. Objects on remote systems can be accessed with the same ease as those on local systems.
Advantages of distributed object systems are scalability, minimizing bandwidth requirements and making it easier for the programmer by handling or hiding complexities across systems.



  • RMI allows objects in one JVM to invoke methods of objects in another JVM.
  • Distributed object systems require that objects running in different address spaces be able to communicate with each other.



 Stub:
The stub is an object, acts as a gateway for the client side. All the outgoing requests are routed through it. It resides at the client side and represents the remote object. When the caller invokes method on the stub object, it does the following tasks:

  • It initiates a connection with remote Virtual Machine (JVM),
  • It writes and transmits (marshals) the parameters to the remote Virtual Machine (JVM),
  • It waits for the result
  • It reads the return value or exception, and
  • It finally, returns the value to the caller.


Skeleton:
The skeleton is an object, acts as a gateway for the server side object. All the incoming requests are routed through it. When the skeleton receives the incoming request, it does the following tasks:

  • It reads the parameter for the remote method
  • It invokes the method on the actual remote object, and
  • It writes and transmits the result to the caller.

3 layers in RMI system:
1. Stub – proxy for remote object.
    Skeleton – remote proxy
    for object.

2.Remote reference layer -Supports communication between stub and       skeleton.

3.Transport Layer - Sets up and manages connections

   between different JVMs.


RMI architecture 


Stub and Skeleton Layers
  1. A client needs a reference to the remote object to invoke any of its methods.
  2. Invocation passes from stub to remote reference layer to transport layer.
  3. Transport layer contacts the skeleton through remote reference layer on the server.
  4. Skeleton checks remote registry to see whether the object is registered.
  5. If registered, the object method is passed to the stub using remote reference layer and transport layer and then to the client object.
Remote Reference Layer

  1. Responsible for unicast point-to-point method invocation.
  2. It defines the number of connections that can be made to a server object depending on the load on the server object.
  3. May deactivate an object and store the data of the object in a file or a database.
  4. If the server is down, try to look out for alternatives to fulfill a request.

Transport layer
  1. RMI uses TCP/IP to communicate between client and server transport layers.
  2. It uses socket to communicate between the client and server transport layer.
  3. Transport layer can implement TCP and UDP protocols.
  4. Transport layer takes care of multiple connections from the client.

No comments:

Post a Comment