Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

Managing MultiReader in multi-treaded application

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


volsky at gmail

Feb 6, 2010, 11:14 PM

Post #1 of 2 (520 views)
Permalink
Managing MultiReader in multi-treaded application

Hi,


I'm trying run a scenario in which I have one index writer and several
readers. I use the MultiReader for searching on several indexes.
The application is multi-threaded so the MultiReader is accessed from
several threads sequentialy.


In some stage during the run I get AlreadyClosedException: this IndexReader
is closed


I wanted an advise about best practices running such a scenario.

Should I use the IncRef and the DecRef for managing the MultiReader
references?

I would be grateful if I could get some advice on this.

Thanks,

Dmitri


lucene at mikemccandless

Feb 7, 2010, 2:17 AM

Post #2 of 2 (475 views)
Permalink
Re: Managing MultiReader in multi-treaded application [In reply to]

IncRef/DecRef is the best way to handle this: you have to ensure the
reader is not closed until 1) your app wants to close it (eg a reopen
has completed), and 2) every query in-flight, that had been using the
reader, has completed.

Lucene in Action 2 (NOTE: I'm a coauthor) has a class
(SearcherManager) that handles these details for you. It also handles
reopening (with optional warming) the reader, including "normal"
readers and near real-time readers. You can download the book's
source code from http://manning.com/hatcher3/.

Mike

On Sun, Feb 7, 2010 at 2:14 AM, Dima Volsky <volsky [at] gmail> wrote:
> Hi,
>
>
> I'm trying run a scenario in which I have one index writer and several
> readers. I use the MultiReader for searching on several indexes.
> The application is multi-threaded so the MultiReader is accessed from
> several threads sequentialy.
>
>
> In some stage during the run I get AlreadyClosedException: this IndexReader
> is closed
>
>
> I wanted an advise about best practices running such a scenario.
>
> Should I use the IncRef and the DecRef for managing the MultiReader
> references?
>
> I would be grateful if I could get some advice on this.
>
> Thanks,
>
> Dmitri
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.