Design: Lock Server

0 views
Skip to first unread message

Shyam Prakash

unread,
Jul 8, 2011, 8:18:36 AM7/8/11
to Freak-Your-Mind [FYM]
How do you design a lock server? - the one serves lock requests to
multiple clients (let's say over the web).

-- How do you define locks?
-- How do you co-ordinate concurrent requests?
-- How do you handle lack of client response after a lock is assigned?
-- Anything else you may think of

Sridivakar Inakonda

unread,
Jul 8, 2011, 8:24:57 PM7/8/11
to freak...@googlegroups.com


Other feature could be :
- client request which is trying to acquire lock should not block, if lock is not available.


API for this may look like this :

class LockServer {
    // For every different resouce, it will create (or return existing) Lock object
    Lock newLock(resourceId);
    void destroyLock(resourceId);
}

class Lock {
    // client request blocks for acquiring the lock
    void acquire(clientId);
    void acquire(clientId, lockTimeOut);

    // client request wont block, if lock is not available
    boolean tryAcquire(clientId);
    boolean tryAcquire(clientId, tryTimeOut);
   
    void release(clientId);

Suresh Kumar Maridi

unread,
Jul 8, 2011, 11:35:25 PM7/8/11
to freak...@googlegroups.com
other features : How do you avoid deadlock situation? 
Bankers Algorithm for assigning locks? may not be applicable.
Detecting Circular wait?
Or Enforcing certain  ordering in acquiring locks?


On Fri, Jul 8, 2011 at 5:48 PM, Shyam Prakash <velu...@gmail.com> wrote:



--
Suresh Kumar Maridi

"it is not our abilities that show what we truly are...... it is our choices"
       - Albus DumbledorE

Shyam Prakash Velupula

unread,
Jul 9, 2011, 2:51:50 AM7/9/11
to freak...@googlegroups.com
Divakar,

Are lockTimeOut and tryTimeOut meant for different purpose? or do they inform the server lock's TTL (validity period)?

release() should also pass resourceId as argument.

Other operation of interest would be "bool extendLease( clientid, resourceid )".

I guess client's also needs to inform what kind of lock is requested, Read, Write etc

Thanks
Shyam Velupula
--
You are limited only by your imagination
Reply all
Reply to author
Forward
0 new messages