lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Wechner <michael.wech...@wyona.com>
Subject Re: How to use setWriteLockTimeout(long) when write.lock already exists
Date Wed, 14 Dec 2011 14:28:44 GMT
Am 13.12.11 19:36, schrieb Michael Wechner:
> Hi
>
> According to
>
> http://www.gossamer-threads.com/lists/lucene/java-dev/37421
>
> one cannot overwrite the default write lock timeout of 1000ms once a 
> write.lock already exists (for example inside a multi-threaded 
> web-application), because in order to use the method  
> setWriteLockTimeout(long)  one would have to
> first create an instance of IndexWriter, but because write.lock 
> already exists the creation will throw a LockObtainFailedException and 
> hence once does not get an instance.
>
> In the link above "Mike" is mentioned that he will create a Jira 
> issue, but it's not clear to me if it ever got created
> and/or that somebody tried to improve this. Any idea?

I think I have found the JIRA issue mentioned in the above email thread:

https://issues.apache.org/jira/browse/LUCENE-621

and according to the test class one can set the timeout ahead of 
initializing the IndexWriter

IndexWriter.setDefaultWriteLockTimeout(2000);
IndexWriter.setDefaultCommitLockTimeout(2000);

IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true);

This seems to work fine.

Thanks

Michael
>
> Just as a suggestions, but I think it would be nice if one could 
> create an IndexWriter instance without actually opening the index in 
> the first place, but rather something like:
>
> IndexWriter iWriter = new IndexWriter();
> iWriter.setDirectory(...);
> iWriter.setAnalyzer(....);
> iWriter.setWriteLockTimeout(75);
> iWriter.open(); // or iWriter.checkout();
> // do something with the index....
> iWriter.close();
>
> WDYT?
>
> Thanks
>
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message