org.compass.needle.terracotta
Class ManagedTerracottaLockAdapter

java.lang.Object
  extended by org.apache.lucene.store.Lock
      extended by org.compass.needle.terracotta.ManagedTerracottaLockAdapter

public class ManagedTerracottaLockAdapter
extends Lock

An adapter ontop of a lock that releases the managed read lock when trying to obtain a Lucene lock and obtains the read lock again once the Lucene lock obtain is done. It is done in order to prevent dead locks when several clients/threads obtain the read lock when the "transaction" starts, and they wait for the lucene lock without actually releasing the read lock for other "write locks (the add file)" to be able to be obtained.

Author:
kimchy

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.store.Lock
Lock.With
 
Field Summary
 
Fields inherited from class org.apache.lucene.store.Lock
failureReason, LOCK_OBTAIN_WAIT_FOREVER, LOCK_POLL_INTERVAL
 
Constructor Summary
ManagedTerracottaLockAdapter(ReadWriteLock rwl, Lock lock)
           
 
Method Summary
 boolean isLocked()
           
 boolean obtain()
           
 boolean obtain(long lockWaitTimeout)
           
 void release()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagedTerracottaLockAdapter

public ManagedTerracottaLockAdapter(ReadWriteLock rwl,
                                    Lock lock)
Method Detail

obtain

public boolean obtain(long lockWaitTimeout)
               throws LockObtainFailedException,
                      IOException
Overrides:
obtain in class Lock
Throws:
LockObtainFailedException
IOException

obtain

public boolean obtain()
               throws IOException
Specified by:
obtain in class Lock
Throws:
IOException

release

public void release()
             throws IOException
Specified by:
release in class Lock
Throws:
IOException

isLocked

public boolean isLocked()
Specified by:
isLocked in class Lock


Copyright (c) 2004-2009 The Compass Project.