Mantis - Resin
Viewing Issue Advanced Details
3464 minor always 04-28-09 09:15 08-20-09 21:05
ferg  
ferg  
normal  
closed  
fixed  
none    
none 4.0.2  
0003464: distributed locking
(rep by Martin Thompson)


The semantics I'm looking for would be similar to the following code.

    public void onLoad()
        throws InterruptedException
    {
        final java.util.concurrent.locks.Lock distributedMasterLock = resinServer.getOrCreateLock("ev-master");

        if (distributedMasterLock.tryLock())
        {
            try
            {
                promoteToMaster(); // blocking
            }
            finally
            {
                distributedMasterLock.unlock();
            }
        }
        else
        {
            startSecondaryBackgroundProcesses(); // non-blocking
            distributedMasterLock.lockInterruptibly();
            try
            {
                promoteToMaster();
            }
            finally
            {
                distributedMasterLock.unlock();
            }
        }
    }

Ideally the locking implementation fits the standard Lock interface and offers semantics like the above. For the secondary waiting on the lock it would be necessary that it aquires the lock almost instantly after the master has released it because of calling unlock or if it dies and just goes away without calling unlock.


Notes
(0004132)
ferg   
08-20-09 21:05   
server/69--