RMI Registry - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

RMI Registry

Description:

public static void rebind(String name, Remote object) public static void unbind(String name) ... bind(), rebind() and unbind() parse name to find out where the ... – PowerPoint PPT presentation

Number of Views:183
Avg rating:3.0/5.0
Slides: 13
Provided by: tklak
Category:
Tags: rmi | rebind | registry

less

Transcript and Presenter's Notes

Title: RMI Registry


1
RMI Registry
Celsina Bignoli bignolic_at_smccd.net
2
Bootstrapping Problem
  • clients on a machine need to connect to servers
    on another machine
  • How does the client know where the server is?
  • server location hard-coded in client code or
    stored in a configuration file
  • user tells client where server is located
  • use a service in a well-known location as a point
    of indirection -gt NAMING SERVICE

3
Why using Naming Services
  • servers migrate
  • there may be many servers
  • servers are partitioned and replicated
  • there may be many servers running on a machine

4
RMI Registry
  • methods are in java.rmi.Naming class
  • public static void bind(String name, Remote
    object)
  • public static void rebind(String name, Remote
    object)
  • public static void unbind(String name)
  • public static String list(String name)
  • public static Remote lookup(String name)
  • above methods are declared in interface
    java.rmi.registry.Registry which extends
    java.rmi.Remote and implemented by
    sun.rmi.registry.RegistryImpl

5
bind(), rebind() and unbind()
  • parse name to find out where the registry is
    running
  • name is a URL with the following format
  • //registryHostport/logical_name
  • Host optional (defaults to localhost)
  • port optional (defaults to 1099)
  • open socket to registry (which is a server
    running on the specified host and listening on
    the indicated port)
  • serialize stub implementing remote object
  • bind it to name

6
lookup() and list()
  • name is a URL as for bind().
  • name for list() only specifies the host and port
    where the registry is located
  • lookup() returns the stub bound to it
  • list() returns complete URLs of all servers bound
    to the registry
  • see code example

7
RMI Registry is a RMI Server
  • Underlying Naming static methods there are a
    Remote interface and its implementation class
  • java.rmi.registry.Registry (interface)
  • defines 5 methods each of which maps to the
    corresponding static method in Naming
  • java.rmi.registry.RegistryImpl (class)

8
How Naming works
  • a static method on naming is called with a given
    URL
  • URL is parsed and the machine/port information is
    to class LocateRegistry which has methods for
    returning the stub for the given registry
  • Naming uses this stub to invoke the appropriate
    method on the registry

9
Application-specific Registry
  • start a registry at an application-specific port
  • using the rmiregistry program
  • rmiregistry 10345
  • from within the code, using static method of
    LocateRegistry class
  • public static createRegistry(int port)

10
Advantages of the RMI Registry
  • easy to administer
  • launch it with rmiregistry, provided as part of
    the JDK distribution
  • easy for clients to find
  • only need to know on which machine it runs
  • easy for clients to use
  • only 5 easy to use methods
  • fast

11
The Need for Directory Service
  • When there are many similar servers between which
    the user can choose
  • ex choosing a printer based on features

12
Security Issues
  • Each process binding a server to the registry
    must run on the same machine where the registry
    runs
Write a Comment
User Comments (0)
About PowerShow.com