Hi, LockFactories are singletons in Lucene. Basically a directory does not even need a LockFactory, the LockFactories are just there to allow "configuring" it in FSDirectory subclasses. The abstract BaseDirectory class handles this for you, as it delegates all calls to the Directory to a given lock factory (this method is final). In your lock factory (ideally also a singleton) the method makeLock is where the lock instance should be created and returned based on the directory instance passed in. This lock instance is responsible to actually lock the directory and also to release the lock. There is no need to forcefully unlock, if you make sure that your code calls Lock#release() in a finally block.
If you have a completely custom directory implementation with a hard-coded, non configureable locking mechanism, it makes no sense to extend BaseDirectory, just extend Directory and implement the abstract method makeLock(). This method is responsible for creating the lock instance that handles actual locking und unlocking. Alternatively you can just hardcode SingleInstanceLockFactory (like RAMDirectory does). clearLock is no longer existent, because it was never used in Lucene. It was there to forcefully remove a lock, which is a bad idea. The only available method is, as said before, Directory#makeLock that should return a Lock instance. Uwe ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: [email protected] > -----Original Message----- > From: Gimantha Bandara [mailto:[email protected]] > Sent: Thursday, May 21, 2015 3:12 PM > To: [email protected] > Subject: Migrating from Lucene 4.10.3 to Lucene 5.10 > > Hi all, > I was going to through > https://lucene.apache.org/core/5_1_0/MIGRATE.html > It is said that the Directory and LockFactory are now refactored. > We have implemented custom directory implementation with > SingleInstanceLockFactory. In Lucene 4.10.3 we have clearLock method. But I > dont find it in 5.1.0. How does Lucene 5.1.0 handle releasing the lock? > > -- > Gimantha Bandara > Software Engineer > WSO2. Inc : http://wso2.com > Mobile : +94714961919 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
