Lab 2: Distributed Locks
Due Date: 10/1/2015
Please work in groups of two.
Your goal in this assignment is to write a simple lock server and client using Akka actors in Scala. There are a variety of distributed mutual exclusion protocols with varying degrees of decentralization and fault tolerance. In this lab the lock service is a single LockServer node: we presume that it does not fail.
Like our other labs this semester, the nodes in the distributed protocol are represented by actors. For our testing the nodes/actors run within a single process, but your code should be designed to work even if nodes/actors run on different machines (i.e., no shared data structures). Note that actors may also be useful to represent concurrency within a node in the distributed protocol. For example, a client or server in your distributed lock system may have internal concurrency with multiple actors to manage multiple locks.
The lock system will follow the Leased Locks protocol discussed in class.
- The lock service appears as a LockServer server actor that handles acquire and release messages on lock objects, and enforces mutual exclusion across client actors. Lock objects have symbolic (string) names.
- The LockClient exposes an API to an application to acquire and release named locks. Upon receiving an acquire request, the client contacts the LockServer to acquire a lease on the lock.
- Clients may cache locks, holding the lease even when the lock is not demanded by the application program. If the lock/lease is cached, the client can complete an acquire request without contacting the LockServer.
- A LockServer may recall a lock at any time. When a client receives a recall notice, it should release the lock as soon as convenient.
Your lock system should provide the following semantics and behavior:
- 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 a maximum of T seconds without compromising the lock service, where T is an input parameter representing the lease duration. Your LockServer should implement an API to emulate failure of the communication path to a specified client, by ignoring any messages received from that client.
-
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 the lease expires, in order to prevent denial of service to the requester.
Implement some tests to demonstrate that your lock service is correct.
Note: You may find useful to use Akka schedulers to manage leases (http://doc.akka.io/docs/akka/snapshot/scala/scheduler.html). The scheduler allows you to schedule a message to be sent to an actor at a specified time or after a specified delay.