-->
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.  [ 4 posts ] 
Author Message
 Post subject: Retrieve the actual FSDirectory?
PostPosted: Tue Nov 24, 2009 12:46 pm 
Newbie

Joined: Tue Jul 22, 2008 11:30 am
Posts: 13
Is there a way I can programatically get the directory that the index is being written too? I've noticed some issues where my app is is either crashing, or being forcibly shutdown and a write.lock file exists in the index directories. I'd like to delete that at startup such that the index can be put anywhere and the code would find it.

I saw that the DirectoryProviders looks promising but i'm having trouble figuring out where to actually get them (or, i guess, a SearchImplementationFactory)

Thanks!


*EDIT*
Actually, i was able to get a DirectoryProvider and eventually a Directory (a lucene one) but I'm having trouble finding what to do with it. there is a clearLock method, but it expects a lock name that i don't know. I'm going to run some tests and just try deleting the files, but i'd like to know the "Right Way" to clear out the lock.

Thanks!


Top
 Profile  
 
 Post subject: Re: Retrieve the actual FSDirectory?
PostPosted: Tue Nov 24, 2009 2:05 pm 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Normally using lucene you use the IndexReader.unlock(directory) in conjuction with IndexReader.isLocked(directory). I've done something similar with a Lucene standalone app where I have a class that checks whether the directory is locked and tries to unlock on application startup.

You can get to the directory using hibernate search and then could apply the unlock method.

It would interesting to know why your application crashes...


Top
 Profile  
 
 Post subject: Re: Retrieve the actual FSDirectory?
PostPosted: Tue Nov 24, 2009 3:27 pm 
Newbie

Joined: Tue Jul 22, 2008 11:30 am
Posts: 13
So far we're seeing this in test where the process is being killed so we can upgrade it.

Doing something like IndexReader.unlock(directory) is great, but it seems like a chicken and the egg though, I need to know the directory to unlock it :) I'll continue to dig around. i noticed that FSDirectory has a File property which is what i want so maybe i can access that directly.


Top
 Profile  
 
 Post subject: Re: Retrieve the actual FSDirectory?
PostPosted: Tue Nov 24, 2009 5:24 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
Quote:
there is a clearLock method, but it expects a lock name that i don't know.

Look into the IndexWriter (Lucene code), you'll see that it uses a constant. Always the same name :-)

What about contributing a patch to optionally "force unlock" the index at startup?
The DirectoryProvider could do that nicely, when some property is set.

Since 3.2-beta1 you'll be able to set any LockFactory: http://opensource.atlassian.com/project ... SEARCH-284
Meaning you can actually disable the locking, IFF you're sure no other application is going to use the same directory.

_________________
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.  [ 4 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.