lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Isakson" <Eric.Isak...@sas.com>
Subject RE: IndexReader.lastModified(); (moved from the User list)
Date Tue, 06 May 2003 14:39:33 GMT
Hmm...I guess I didn't understand the problem so well. Taking a 1 second penalty for every
modification would probably not be a good idea :(

-----Original Message-----
From: Rob Outar [mailto:routar@ideorlando.org] 
Sent: Tuesday, May 06, 2003 10:33 AM
To: Eric Isakson; lucene-dev@jakarta.apache.org
Subject: RE: IndexReader.lastModified(); (moved from the User list)


I have not delved into the source code as much as I would like to but I am not sure if the
below would fix my problem.  Creating the index is OK, but the problem occurs when modifying
the index (which means you need to get a new IndexSearcher).  If the modification to the index
is under 1 second the ext2-fs will not update the last modification date of the index thus
making
IndexReader.lastModified() useless in terms of checking if the index has changed.  If the
below code is invoked for all modifications to the index then it may work.

Thanks,

Rob


-----Original Message-----
From: Eric Isakson [mailto:Eric.Isakson@sas.com]
Sent: Tuesday, May 06, 2003 9:48 AM
To: lucene-dev@jakarta.apache.org
Cc: Rob Outar
Subject: RE: IndexReader.lastModified(); (moved from the User list)


Could this be fixed by adding a conditional sleep in this block of code from IndexWriter.
You would use this by setting the System property "org.apache.lucene.SleepOnIndexCreate" to
an int value in milliseconds of how long to sleep when creating a new index. I've attached
a patch. I don't have a linux system to try this out on, perhaps Rob could apply this patch
and see if it fixes his problem.

  public IndexWriter(Directory d, Analyzer a, final boolean create)
       throws IOException {
    directory = d;
    analyzer = a;

    Lock writeLock = directory.makeLock("write.lock");
    if (!writeLock.obtain())                      // obtain write lock
      throw new IOException("Index locked for write: " + writeLock);
    this.writeLock = writeLock;                   // save it

    synchronized (directory) {			  // in- & inter-process sync
      new Lock.With(directory.makeLock("commit.lock")) {
	  public Object doBody() throws IOException {
	    if (create) {
			segmentInfos.write(directory);
			String sleepOnCreate =
				System.getProperty("org.apache.lucene.SleepOnIndexCreate");
			if (sleepOnCreate != null) {
				try {
					int sleepTime = Integer.parseInt(sleepOnCreate);
					Thread.sleep(sleepTime);
				} catch (NumberFormatException e) {
					e.printStackTrace();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
	    }
	    else
	      segmentInfos.read(directory);
	    return null;
	  }
	}.run();
    }
  }

Eric
--
Eric D. Isakson        SAS Institute Inc.
Application Developer  SAS Campus Drive
XML Technologies       Cary, NC 27513
(919) 531-3639         http://www.sas.com



-----Original Message-----
From: Tatu Saloranta [mailto:tatu@hypermall.net]
Sent: Tuesday, May 06, 2003 9:06 AM
To: Lucene Users List
Subject: Re: IndexReader.lastModified();


On Tuesday 06 May 2003 05:42, Rob Outar wrote:
> Yeah it looks like I am going to have to handle it internally instead 
> of relying on IndexReader.lastModified(), oh well so much for 
> cross-platform-ism :-)

[regarding ext2-fs 'feature' on Linux]

I think this 'feature' might be useful thing to document in a FAQ. Perhaps there should be
a platform-dependancies FAQ (or sub-section). Wasn't there also some concern regarding Windows
platform, where deleted status of a file was not reliably accessed by Java (or something similar)?

Also, do you think ext3 has same problem? (or if it has, other new journaling file systems).

-+ Tatu +-


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message