You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ry...@apache.org on 2007/07/03 09:31:34 UTC
svn commit: r552698 - in /lucene/solr/trunk: CHANGES.txt
src/java/org/apache/solr/update/DirectUpdateHandler2.java
src/test/org/apache/solr/update/AutoCommitTest.java
Author: ryan
Date: Tue Jul 3 00:31:32 2007
New Revision: 552698
URL: http://svn.apache.org/viewvc?view=rev&rev=552698
Log:
SOLR-283: autoCommit after delete
Modified:
lucene/solr/trunk/CHANGES.txt
lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java
lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java
Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?view=diff&rev=552698&r1=552697&r2=552698
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Tue Jul 3 00:31:32 2007
@@ -103,6 +103,8 @@
2. autoCommit/maxDocs was not working properly when large autoCommit/maxTime
was specified (klaas)
+ 3. SOLR-283: autoCommit was not working after delete. (ryan)
+
Other Changes
1. SOLR-135: Moved common classes to org.apache.solr.common and altered the
build scripts to make two jars: apache-solr-1.3.jar and
Modified: lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java?view=diff&rev=552698&r1=552697&r2=552698
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java Tue Jul 3 00:31:32 2007
@@ -304,6 +304,10 @@
} finally {
iwCommit.unlock();
}
+
+ if( tracker.timeUpperBound > 0 ) {
+ tracker.scheduleCommitWithin( tracker.timeUpperBound );
+ }
}
// why not return number of docs deleted?
@@ -351,6 +355,10 @@
}
numDocsDeleted.getAndAdd(totDeleted);
madeIt=true;
+
+ if( tracker.timeUpperBound > 0 ) {
+ tracker.scheduleCommitWithin( tracker.timeUpperBound );
+ }
} finally {
if (!madeIt) {
numErrors.incrementAndGet();
@@ -568,7 +576,7 @@
}
log.info("closed " + this);
}
-
+
/** Helper class for tracking autoCommit state.
*
* Note: This is purely an implementation detail of autoCommit and will
@@ -605,6 +613,23 @@
SolrCore.log.info("AutoCommit: " + this);
}
+ /** schedeule individual commits */
+ public synchronized void scheduleCommitWithin(long commitMaxTime)
+ {
+ // Check if there is a commit already scheduled for longer then this time
+ if( pending != null &&
+ pending.getDelay(TimeUnit.MILLISECONDS) >= commitMaxTime )
+ {
+ pending.cancel(false);
+ pending = null;
+ }
+
+ // schedule a new commit
+ if( pending == null ) {
+ pending = scheduler.schedule( this, commitMaxTime, TimeUnit.MILLISECONDS );
+ }
+ }
+
/** Indicate that documents have been added
*/
public void addedDocument() {
Modified: lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java?view=diff&rev=552698&r1=552697&r2=552698
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/update/AutoCommitTest.java Tue Jul 3 00:31:32 2007
@@ -156,6 +156,13 @@
// But not this one
assertQ("should find none", req("id:530") ,"//result[@numFound=0]" );
+ // Delete the document
+ assertU( delI("529") );
+ assertQ("deleted, but should still be there", req("id:529") ,"//result[@numFound=1]" );
+ // Wait longer then the autocommit time
+ Thread.sleep( 1000 );
+ assertQ("deleted and time has passed", req("id:529") ,"//result[@numFound=0]" );
+
// now make the call 10 times really fast and make sure it
// only commits once
req.setContentStreams( toContentStreams(
@@ -164,7 +171,7 @@
handler.handleRequest( req, rsp );
}
assertQ("should not be there yet", req("id:500") ,"//result[@numFound=0]" );
- assertEquals( 1, tracker.autoCommitCount );
+ assertEquals( 2, tracker.autoCommitCount );
// Wait longer then the autocommit time
Thread.sleep( 1000 );
@@ -173,6 +180,6 @@
assertQ("now it should", req("id:500") ,"//result[@numFound=1]" );
assertQ("but not this", req("id:531") ,"//result[@numFound=0]" );
- assertEquals( 2, tracker.autoCommitCount );
+ assertEquals( 3, tracker.autoCommitCount );
}
}