When my server restarts, I have a little procedure that validates and "sorts
out" the index in case the server crashes mid-indexing/optimizing, what it
does is it checks for locks and frees them if need be then it optimizes the
whole thing (as a precaution) here's the code I use, try it out in your
lucene init:


                try {
                        Directory directory =
FSDirectory.getDirectory(indexPath,false);
                        if ( directory.list().length == 0 ) clear() ; //
Create a new index
                        Lock writeLock = directory.makeLock(writeFileName); 
                        if (!writeLock.obtain()) {
                                IndexReader.unlock(directory) ;
                        } else {
                                writeLock.release() ;
                        }
                } catch (IOException e) {
                        logger.error("Index Validate",e) ;
                }

Try it out, hope it helps.

Nader Henein


-----Original Message-----
From: Rosen Marinov [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 03, 2004 5:52 PM
To: Lucene Users List
Subject: change directory


Hi all,

I have a good working index about 3 GB in one directory
for example in c:/index1

now i want to change the computer and directory for example
to d:/index2    (is this possible ???)

and when i copy it to the new pc and directory  on 
IndeaxReader(indexpath) i get 
    
      java.io.IOException: Lock obtain timed out
        at org.apache.lucene.store.Lock.obtain(Lock.java:97)
        at org.apache.lucene.store.Lock$With.run(Lock.java:147)
        at org.apache.lucene.index.IndexReader.open

before coping i closed all java aplications, index was with closed writers,
readers, serachers, terms and etc ... i have finally clauses to close all
this and shut down function, all my methods which works with index are
synchronized.

10x fopr help in advance



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to