-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Very dynamic indexBase directory
PostPosted: Fri Jan 29, 2010 2:11 pm 
Newbie

Joined: Fri Jan 29, 2010 11:54 am
Posts: 3
Hello,

i use HibernateSearch 3.1.1 GA with Spring 3.0 for the development of an webapplication.
HibernateSearch is configured through the application context within Springs LocalsessionFactoryBean (setting hibernate.search.default.indexBase and registering the FullTextIndexEventListener to the specific post-* events etc.).

This works just fine as long as things stay static.

In addition to the standard setup we use something similar to Spring's AbstractRoutingDataSource (http://blog.springsource.com/2007/01/23 ... e-routing/).

The user can change the Datasource within the application. The Index should be changed at the same time. A similar Question already arose in viewtopic.php?f=9&t=984619 i also checked some other topics on this forum about dynamic setting of the indexBase directory, but these were not 100% comparable (setting index.Base to the value of a JVM-Option value for example). My Problem seems to be that the location indexBase has to point to can change on virtually every new request.

What i did try is to extend the FSDirectoryProvider and override the initialize() method. Problem is that this is only called once when the whole configuration is set up. However i would require it to be called every time the currently active Datasource changes. Is there a way to re-initialize all the already existing FSDirectoryProviders? Maybe re-initialize the whole SearchFactory with the already existing Configurations/Mapped Classes etc. but with a dynamic change in the FSDirecotryPoviders?

I also tried overriding the getDirectory() method. As the javadoc already states this must be threadsafe. Thus this works for searching for elements (as getDirectory is called from the same thread there) but will not work for modifying events that write to the index (as these are fired from different threads and my threadlocal held active Datasource is thus not accessible :().

Is there any other solution / different approach to handle this kind of dynamic Datasource scenario?
Maybe use one index and add a prefix to the documents within it and filter for this prefix again when searching?

Thanks in advance for any answers.


Top
 Profile  
 
 Post subject: Re: Very dynamic indexBase directory
PostPosted: Fri Jan 29, 2010 2:45 pm 
Newbie

Joined: Fri Jan 29, 2010 11:54 am
Posts: 3
Thought about the solution with overriding FSDirecotryPovider a bit.

As there is only one (per mapped class) FSDirecotryPovider globally and it doesn't (and shouldn't!) know about what Datasource the currently active user uses, this solution wont work :(


Top
 Profile  
 
 Post subject: Re: Very dynamic indexBase directory
PostPosted: Sun Jan 31, 2010 9:19 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
How many different datasources do you expect to manage?

As a datasource configuration is static, wouldn't it be reasonable to have a pool of Hibernate SessionFactories, one per datasource?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Very dynamic indexBase directory
PostPosted: Mon Feb 01, 2010 8:33 am 
Newbie

Joined: Fri Jan 29, 2010 11:54 am
Posts: 3
Hi.
I guess between 2 and 5 are common.
But hmn i can't really answer the question because users may create new datasources within the application.
The connection data for further Databases is stored within the main Database and may be edited by the user.


Top
 Profile  
 
 Post subject: Re: Very dynamic indexBase directory
PostPosted: Thu Feb 04, 2010 5:06 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
having several isolated Hibernate+Search will just consume some additional memory.
I'd use separate SessionFactories and keep them isolated, so you can add new ones having different configurations and start/stop them independently.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.