Option b) sounds simpler and sufficient to me. I don't see why you would need to involve RMI for something as simple as this. I use something similar to your b) option for some indices behind http://www.simpy.com/ . I don't store IndexSearcher in the servlet context, though - I just have some logic like this:
/** * Returns an instance of [EMAIL PROTECTED] IndexDescriptor} for the given * <code>indexID</code>, which must represent an absolute file * path to the index directory. * <p/> * This method caches [EMAIL PROTECTED] IndexDescriptor}s in a LRU Map and * first tries to retrieve them from there. * <p/> * If the specified index has been changed since the the last time * it was used, its [EMAIL PROTECTED] Searcher} is reloaded. * * @param indexID the full path to the index directory * @return an instance of [EMAIL PROTECTED] IndexDescriptor} * @throws SearcherException if the given index cannot be accessed */ IndexDescriptor getUserSearcherIndexDescriptor(String indexID) throws SearcherException { File indexDir = validateIndex(indexID); IndexDescriptor indexDescriptor = getIndexDescriptorFromCache(indexDir); try { // if this is a known index if (indexDescriptor != null) { // if the index has changed since this Searcher was created, make a new Searcher long currentVersion = IndexReader.getCurrentVersion(indexDir); if (currentVersion > indexDescriptor.lastKnownVersion) { indexDescriptor.lastKnownVersion = currentVersion; indexDescriptor.searcher = new LuceneUserSearcher(indexDir); } } // if this is a new index else { indexDescriptor = new IndexDescriptor(); indexDescriptor.indexDir = indexDir; indexDescriptor.lastKnownVersion = IndexReader.getCurrentVersion(indexDir); indexDescriptor.searcher = new LuceneUserSearcher(indexDir); } return cacheIndexDescriptor(indexDescriptor); } catch (IOException e) { throw new SearcherException("Cannot open index: " + indexDir, e); } } IndexDescriptor is a simple struct-like class. Otis --- Rupinder Singh Mazara <[EMAIL PROTECTED]> wrote: > hi erik > > thanks for the warning and the code. > Let me re-phrase the question, > > i have a index generated by lucene, i need to have the search > capabilty > to have a high availabilty. What solutions would be the most optimal > > Currentlly i have two senarions in mind > a) setup a RMI based app. that on start-up initializes a > IndexSearcher > object > and waits for invocation of a method like Vector > executeQuery(Query ) > > b) create a web based app(jsp/servlet or struts) that initialises > the > IndexSearcher object, and stores in the servletContext on > intialization, and > all request invoke the Hits search(Query q) > > with senario a) i can have more control over updates, insert, and > deletes > where as with senario b) has higher availabilty > > I want to create and store the IndexSearcher object, during > initailization > to save on > mutlitple open and reads. once updates are ready signal can be sent > to > block further searches while the updates are integrated into the > existing > index. > > > > >-----Original Message----- > >From: Erik Hatcher [mailto:[EMAIL PROTECTED] > >Sent: 20 August 2004 11:13 > >To: Lucene Users List > >Subject: Re: lucene and ejb applications > > > > > >What would be the best way? Use Lucene outside of EJB. It's quite > >silly to make such a decision "purely due to a policy decision" when > >the technicalities of it show that it is an unwise decision. > > > >You're going to navigate Hits through a session bean? And as you > said, > >the EJB spec says not to use file I/O from EJB's. That is a good > >recommendation if you are distributing your system across servers > and > >replication is occurring - if another call to a session bean occurs > and > >ends up on a different server, then the file handle is lost. > > > >I violate the spec in my JavaDevWithAnt project and have one mode > where > >I have a stateless session bean returning search results: > >http://www.ehatchersolutions.com/JavaDevWithAnt - but I definitely > do > >not recommend it. It works when you are in a single-server > >environment. > > > >In summary - EJB and Lucene are not a good mix - don't force it just > to > >be buzzword compliant. > > > > Erik > > > > > >On Aug 20, 2004, at 4:32 AM, Rupinder Singh Mazara wrote: > > > >> hi all > >> > >> purely due to a policy decision, we would like to host our > lucene > >> search > >> application , in a j2ee container, preferable by means of a ejb. > >> Since access to java.io is restricted by the ejb specification, > what > >> would > >> be the best way to create desgin the application ? > >> i have taken a look at [EMAIL PROTECTED] but it my relies on mbeans > and > >> not a > >> session bean > >> does any one have pointers or samples that can be looked at --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]