Assignments
Links
Schedule
Syllabus

Assignment 2: Service Discovery

This is the first part of a two-part assignment to implement remote object invocation (RMI). We won't have time to implement a general RMI framework, but we will focus on the following objectives:

  1. implement your own abstract RemoteObject class,
  2. implement an object-server registry,
  3. locate a object server through a registry,
  4. manually create a sample stub and implementation object,
  5. register a sample object implementation,
  6. and instantiate a sample stub as a remote interface to the sample implementation.
For the first part of the project, this assignment, you need only complete items 1-3 and 5.

Creating a RemoteObject Class

Every object that we will access remotely will subclass the RemoteObject class, which we have to create. Sun's RMI provides an interface Remote to represent remote objects, but to get us started, we'll use an abstract class.

For testing, implement the methods

  • public int getPort(); // Return the port on which the server listens for commands on the object.
  • public String getHostName(); // Return the name of the server hosting the object.

Creating Registry

Write a program that listens to a port for three commands:
  • rebind (service-name, port): associate a service name with a host name and port number to be used to retrieve a remote object implementing the service name.
  • unbind (service-name):: remove a registry entry established with the rebind command.
  • lookup (service-name): return the stub to access a service.
Your program should keep a thread-safe table storing the locations from which objects can be retrieved. The program is only a registry -- it provides location information, not the objects.

Locating the Registry

Write a service discovery class and a program that instantiates and tests your class. Your service discovery class should have the following methods
  • public ServiceDiscovery (String hostName, int port): A constructor that looks for the registry at the hostname and port arguments. Your constructor should throw exceptions if necessary.
  • public RemoteObject lookup (String serviceName): Contact the registry, check if the service name is registered, and (eventually) return an implementation of the remote object. If no such service is registered, then return null or throw an exception. For this part of the assignment, you do not need to actually return the instantiation of a remote object, but you should check for the service entry in the registry.

Grading

  • D: Your code must compile.
  • C: All of the above, plus your code must be able to locate a registry, register a service, unregister a service, and find a service. You do not have to create the remote object for this assignment.
  • B: All of the above, plus:
    • Your code must be cleanly documented and tested. It is your responsibility to create a test suite and submit its output.
    • Your registry program must be multi-threaded and thread-safe. Demonstrate the safety!
  • A: All of the above, plus
    • Your code must be cleanly written using class-member constants where appropriate and class methods.
    • Write a tutorial for how to start the registry and service locater.
    • Measure the throughput of requests per second that your registry can handle. How much time elapses during service lookup?
  • Extra credit: Implement, document, and test any of the following
    • Use multicast to locate a registry.