CPS 212: Distributed Information Systems
home calendar topics work resources

Lab 1: Distributed Locks

Due Date: 10/24/2007 before class.

Your goal in this assignment is to produce a simple distributed lock server and client using Java Remote Method Invocation (RMI). Your lock service will be similar to the locking mechanisms used in distributed file systems such as AFS, NQ-NFS, and Frangipani.

To application threads running in a client, a lock is an instance of a Mutex class with Acquire and Release primitives that enforce mutual exclusion across threads. To the client (e.g., your Mutex class implementation), the lock service should appear as a class called LeasedToken that implements a Remote interface with Acquire and Release methods to provide mutual exclusion among threads running on different clients. (The client may obtain instances of LeasedToken by name from the RMI registry.)

There exist a variety of distributed mutual exclusion protocols with varying degrees of decentralization and fault tolerance (see the text). Implementing the locks in RMI will force us to use a less reliable and less scalable approach in which the current state of each lock is represented at a fixed location, e.g., a centralized server. However, clients can cache lock tokens and leases as the basis for a lock service that is reasonably scalable and tolerant of most client and network failures.

Your lock system should provide the following semantics and behavior:

  1. Mutual exclusion is guaranteed in the absence of failures. The lock service also tolerates "brief" transient failures of the communication system. More specifically, the communication system may fail for T seconds or less without compromising the lock service, where T is an input parameter.

  2. Your implementation should cache locks so that releases and subsequent acquires of a given lock by a thread can complete without the need to contact the server. In other words, a lock holder may Acquire and Release a given lock repeatedly without contacting the server, as long as the lease is valid and the client is not aware of any intervening Acquire request by another client.
  3. If a client requests to Acquire a lock whose holder is disconnected from the server, then the server unilaterally seizes the requested lock from the disconnected client after T seconds in order to prevent denial of service to the requester. If a disconnected client reconnects after one of its locks has been seized, that client is notified (by an exception) that it no longer holds the lock.

Implement some tests to demonstrate that your lock service is correct.

Note: you may use any classes from the Java environment in your implementation. Java includes several classes with functionality related to this assignment, including one called Lease. I suspect that these classes will not be useful for this assignment, but you are welcome to use them if they turn out to be useful.

You may use SOAP or XMLRPC instead of RMI if you prefer.