Java Remote Method Invocation RMI - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Java Remote Method Invocation RMI

Description:

Access to non-Java objects (as well as Java objects) DCOM. Access to Win32 objects ... Enable distributed computing and communication but maintain language-specific ... – PowerPoint PPT presentation

Number of Views:103
Avg rating:3.0/5.0
Slides: 20
Provided by: YUAN88
Category:

less

Transcript and Presenter's Notes

Title: Java Remote Method Invocation RMI


1
Java Remote Method Invocation (RMI)
  • Yuan Chen
  • (yuanchen_at_cc.gatech.edu)

2
Related Technologies
  • Message Passing (sockets)
  • Flexible and sufficient for general communication
  • Exchange protocol complicated and error-prone
  • RPC (Remote Procedure Call)
  • Platform-specific
  • Procedure call
  • Static stub
  • CORBA
  • System heterogeneity, language heterogeneity
  • Language neutral object model
  • Access to non-Java objects (as well as Java
    objects)
  • DCOM
  • Access to Win32 objects

3
Goals
  • Language integration simplicity and naturalness
  • Enable distributed computing and communication
    but maintain language-specific (Java) object
    semantics as much as possible
  • Similar interfaces as if object local, preserve
    some behavior
  • Keep it simple expose exceptions related to
    distributed interaction
  • System Integration
  • Use safety, runtime class loading, security,
    garbage collection already provided by JVM
  • Support different invocation semantics
  • unicast, multicast (like with Subcontracts in
    Spring)
  • Support different reference semantics
  • persistent, non-persistent references to remote
    objects
  • Multiple transports for pair of endpoints
  • UDP, TCP (like in Network Objects)

4
Distributed Object Model
  • Distributed Object Model
  • Remote object
  • Live on server
  • Object whose methods can be accessed from another
    address space
  • Remote interface
  • Declare exposed methods
  • Like a proxy for the remote object
  • Remote References
  • Refer to remote objects
  • Invoked on client exactly like local object
    references
  • RMI
  • Non-remote object passed by value
  • Remote object passed by reference
  • RemoteException
  • Java Object Model
  • Object
  • Interface
  • declare a set of methods for Java object without
    implementation
  • Method Invocation
  • primitive type passed by value
  • object passed by reference

5
Object
classes
Interfaces
Remote
RemoteObject
IOException
RemoteServer
RemoteException
UnicastRemoteObject
Remote Interface
extension
implementation
Stub
Server Impl
6
  • Stub
  • Live on client
  • Pretends to be remote object
  • Skeleton
  • Live on server
  • Receive requests from stub
  • Talk to true remote object
  • Deliver response to stub

7
Java RMI Details
  • Remote reference
  • Client stubs have same remote interface as the
    remote object, therefore Java treats them as
    objects with same type
  • Remote method invocation
  • Same syntax, but exceptions have to be caught
  • Exception tells only that something happened
  • Some semantics have to change
  • Client has a reference to remote object
  • Methods of class Object (equal, hashCode) dont
    involve a remote call, so can operate on
    reference
  • Registry
  • A registry is a running process on a host machine
  • Name and look up remote objects
  • Servers can register their objects
  • Clients can find server objects and obtain a
    remote reference

8
Remote Interface vs. Remote Class
  • Remember that the reference is to an interface
  • You must make references, arrays, etc. out of the
    interface type, not the implementation type
  • You cant cast the remote reference to a normal
    reference
  • So name your Remote Objects with Impl (so you
    dont get confused)

9
Parameter Passing
  • Primitive types
  • passed by value
  • Remote objects
  • passed by reference
  • Non-remote objects
  • passed by value
  • uses Java Object Serialization

10
Java RMI Layers
Java Virtual Machine
Java Virtual Machine
Client Object
Remote Object
Stub
Skeleton
TCP
11
System Architecture
Client
Server
Application
Stubs
Skeleton
Remote Reference layer
RMI System
Transport
  • Stub/Skeleton layer client proxy and server
    dispatcher
  • Remote reference layer
  • Invocation semantics unicast, multicast,
    replication strategy
  • Reference semantics live or persistent,
    reconnection strategies
  • Transport layer actual connection setup and
    management
  • Deals with communications
  • Connection management
  • Dispatching messages between stub and skeleton
  • Distributed Garbage Collection

12
Pickling
  • The process of creating a serialized
    representation of objects
  • Pickling defines the serialized form
  • Meta information type of each object,
    relationships between objects
  • Values
  • Used for object transmission across address space
  • Serialized representation of objects
  • object type
  • object persistent state
  • relationships between objects within a stream
  • object implementation info
  • Pickling remote object
  • Stubs/skeletons marshal/unmarshal pickled
    streams
  • When marshalling remote object, marshal stream
    embeds URL info of the stub code
  • On unmarshalling, marshal stream loads stub code
    if its not available locally

13
Dynamic Stub Loading
14
Remote Method Call
15
Enhancements in J2SE 5.0
  • Dynamic Generation of Stub Classes
  • Standard SSL/TLS Socket Factory Classes
  • Launching rmid or a Java RMI Server from
    inetd/xinetd
  • Serialization Enhancements

16
Summary
  • RMI is a very clean API
  • Access to Remote Object
  • Java-to-Java only
  • Client-Server Protocol
  • High-level API
  • Transparent
  • Lightweight
  • Easy way to write distributed programs
  • Wire protocol may need improvement for
    large-scale problems

17
(No Transcript)
18
JEDI Example
19
Summary
  • Simple and flexible scheme
  • Dynamic method invocation
  • Scalable
  • interacting with many remote objects at the same
    time
  • Lack some RMI functionality
  • Static type-check
  • Large data (JEDI cannot support more than 64K of
    data)
  • Advanced security capability
  • Persistent objects
  • Natural remote call semantics
Write a Comment
User Comments (0)
About PowerShow.com