Programming assignment 2

Basic RMI programming

DUE: Nov. 6, 2008, 2pm

NOTE: THIS IS CHANGED FROM THE ORIGINAL DUE DATE OF Nov. 4!

In this assignment you will implement a basic RMI-based system inspired by Linda, the topic of one of the research paper assignments (paper is here). You will implement a server and client. The server will make available three of the basic Linda operations:

Clarification: in should be blocking, inp should not. I received this question in office hours.

You are not responsible for the rd/rdp operations discussed in the paper. The three operations should be the only publicly callable methods on the Server object: the internal server state must be completely hidden from the outside world. The client makes outgoing calls only. The server does not call the client ever.

You must write the code to deal with potential contention due to more than one client interacting with the server at the same time.

You should represent the tuples as pairs: a "type" identifier string and an associated data element. For example, a type identifier may be "person", and the associated data element would be a HashMap containing key/value pairs for their name, age, and address. For example:

class TupleData {
  String Type;
  HashMap < String,Object > Data;

  public TupleData(String t) {
    this.Type = t;
    this.Data = new HashMap < String,Object > ();
  }

  public void setDataElement(String key, Object value) {
    // code
  }

  public Object getDataElement(String key) {
    // code
  }
}

You are to use Java for this unless you have a desire to use a C++ RMI system such as CORBA or Babel. You will need to get permission from me if you wish to use something other than Java RMI. You are not allowed to use any Linda-like service that already exists, such as JavaSpaces or it's derivatives and relatives. All code is to be written from scratch.

The server should simply act as the maintainer of the tuple space. For this problem, you should write three clients.

  1. A tuple producer that creates a set of tuples to place in the tuple space. For this problem, these tuples will be tagged with a type "Work", and the data associated them will be a single randomly selected integer that ranges from 1 to 60.
  2. A tuple consumer that looks for tuples of type "Work", extracts them when found, and sleeps for the amount of time indicated by the extracted tuple. When it finishes, it should place a new tuple in the space of type "CompletedWork", and repeat the process of looking for "Work" to work on. The CompletedWork tuples should carry data with them to indicate how much work (how long the worker slept) was performed.
  3. A tuple consumer that looks for tuples of type "CompletedWork", and simply prints out a message along the lines of "Work completed that took N seconds", where N is the amount that the worker slept.

To support this, your code should include:

The clients and server must be able to all run on separate machines. It is fair for testing to simply assume that the server runs on one machine, and all of the clients run on another machine. The clients should not be dependent on this colocation in any way though.

Please turn in your code and a brief readme that indicates how to build and run it. Please turn the code in as a tar or zip archive. Individual files attached to an e-mail are a bit of a pain to keep track of.

For your reference, here are a few links that will be useful.