1 / 12

RMI Registry

RMI Registry. Celsina Bignoli bignolic@smccd.net. 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

kendall
Download Presentation

RMI Registry

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RMI Registry Celsina Bignoli bignolic@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 -> 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 //registryHost:port/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

More Related