CS 5523 Operating Systems
Laboratory 2 - Spring 2002
Implementation a Remote Repository
using Java Remote Invocation

Objectives:

Overview:

In this laboratory you will write and test a shared file repository based on Java RMI. The project is divided on three parts:

Note: Prior to starting this laboratory you should be sure that you have successfully run the SimpleHello remote server. If you have any problems in doing this, see your instructor.

Requirements:

Part I: The nonremote implementation

As part of this assignment, you will need to implement two interfaces: the Directory and the FileObject (e.g., DirectoryImpl and FileObjectImpl). In Parts II and III, the Directory will become a remote interface and FileObject will be passed to a remote object. You will need to modify them as described below.

Part II: Remote version with no synchronization

In Part II you will convert the Directory interface and the DirectoryImpl class to support remote invocation. As in part I, you can design a server class that instantiates a Directory object and registers it with registry. Alternatively, you can include that code in the main method of DirectoryImpl. In either case, pass the port number of the registry and the name that the Directory object will be registered under as command line arguments. These values should should be into the constructor of the DirectoryImpl class.

The FileObject interface represents a local object that will be passed remotely by value. In the remote implementation, the FileObjectImpl class must implement Serializable. The added complication in this problem is that the default technique for serialization will probably not work, because data from the object is kept on disk and local files only have meaning in a local environment. You will need to define your own methods with the following signature:

   private void readObject (ObjectInputStream in) throws 
                     IOException, ClassNotFoundException;
   
   private void writeObject (ObjectOutputStream out)
                     throws IOException;
You can call:
    in.defaultReadObject( );
in the readObject to read in the default serialization first.

You can call:

    out.defaultWriteObject( );
in the writeObject method to write the default serialization before writing the special information.

Note: it would be wise to test the serialization of FileObjectImpl locally before trying to pass it by value in a remote call.

You should test your remote invocation and all of the methods with a single client.

Part III: Synchronization for multiple clients

If more than one client accesses your remote objects, you must provide synchronization. Each java object has its own monitor. When you declare a method to be synchronized, e.g.:

     public synchronized Vector getList( ) throws RemoteException
the code within the method is executed mutually exclusively with the other synchronized methods in the object. The simplest way to handle synchronization, is to declare each method to be synchronized. This approach can be very inefficient. To receive full credit, you must implement a readers-writer type synchronization for your DirectoryImpl. You must also include in your writeup a discussion of your approach.

Test your synchronization by creating multiple simultaneous clients to access the repository.


Note: This line added to client.policy takes care of writing, reading, and deleting files in one's home directory or subdirectories:
permission java.io.FilePermission "${user.home}${/}-", "read,write,delete"; 


Last Revision: April 6, 2002 at 1:35 pm by Kay A. Robbins. This material may be used for educational purposes provided that the source is credited.