lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r824380 - in /lucene/solr/trunk/src: java/org/apache/solr/update/DirectUpdateHandler2.java test/org/apache/solr/update/DirectUpdateHandlerTest.java
Date Mon, 12 Oct 2009 15:18:08 GMT
Author: koji
Date: Mon Oct 12 15:18:08 2009
New Revision: 824380

URL: http://svn.apache.org/viewvc?rev=824380&view=rev
Log:
SOLR-670: Rollback should reset not only adds/deletesById/deletesByQuery counts but also cumulative
counts of them.
[ Show ยป ]
Koji Sekiguchi added a comment - 12/Oct/09 06:48 AM Rollback should reset not only adds/deletesById/deletesByQuery
counts but also cumulative counts of them.

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java
    lucene/solr/trunk/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java

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?rev=824380&r1=824379&r2=824380&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java Mon Oct 12
15:18:08 2009
@@ -470,9 +470,12 @@
     }
     finally {
       iwCommit.unlock();
-      addCommands.set(0);
-      deleteByIdCommands.set(0);
-      deleteByQueryCommands.set(0);
+      addCommandsCumulative.set(
+          addCommandsCumulative.get() - addCommands.getAndSet( 0 ) );
+      deleteByIdCommandsCumulative.set(
+          deleteByIdCommandsCumulative.get() - deleteByIdCommands.getAndSet( 0 ) );
+      deleteByQueryCommandsCumulative.set(
+          deleteByQueryCommandsCumulative.get() - deleteByQueryCommands.getAndSet( 0 ) );
       numErrors.set(error ? 1 : 0);
     }
   }

Modified: lucene/solr/trunk/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java?rev=824380&r1=824379&r2=824380&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java Mon Oct
12 15:18:08 2009
@@ -176,15 +176,29 @@
     // commit "A"
     SolrCore core = h.getCore();
     UpdateHandler updater = core.getUpdateHandler();
+    assertTrue( updater instanceof DirectUpdateHandler2 );
+    DirectUpdateHandler2 duh2 = (DirectUpdateHandler2)updater;
     CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
     cmtCmd.waitSearcher = true;
+    assertEquals( 1, duh2.addCommands.get() );
+    assertEquals( 1, duh2.addCommandsCumulative.get() );
+    assertEquals( 0, duh2.commitCommands.get() );
     updater.commit(cmtCmd);
+    assertEquals( 0, duh2.addCommands.get() );
+    assertEquals( 1, duh2.addCommandsCumulative.get() );
+    assertEquals( 1, duh2.commitCommands.get() );
 
     addSimpleDoc("B");
 
     // rollback "B"
     RollbackUpdateCommand rbkCmd = new RollbackUpdateCommand();
+    assertEquals( 1, duh2.addCommands.get() );
+    assertEquals( 2, duh2.addCommandsCumulative.get() );
+    assertEquals( 0, duh2.rollbackCommands.get() );
     updater.rollback(rbkCmd);
+    assertEquals( 0, duh2.addCommands.get() );
+    assertEquals( 1, duh2.addCommandsCumulative.get() );
+    assertEquals( 1, duh2.rollbackCommands.get() );
     
     // search - "B" should not be found.
     Map<String,String> args = new HashMap<String, String>();
@@ -213,9 +227,17 @@
     // commit "A", "B"
     SolrCore core = h.getCore();
     UpdateHandler updater = core.getUpdateHandler();
+    assertTrue( updater instanceof DirectUpdateHandler2 );
+    DirectUpdateHandler2 duh2 = (DirectUpdateHandler2)updater;
     CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
     cmtCmd.waitSearcher = true;
+    assertEquals( 2, duh2.addCommands.get() );
+    assertEquals( 2, duh2.addCommandsCumulative.get() );
+    assertEquals( 0, duh2.commitCommands.get() );
     updater.commit(cmtCmd);
+    assertEquals( 0, duh2.addCommands.get() );
+    assertEquals( 2, duh2.addCommandsCumulative.get() );
+    assertEquals( 1, duh2.commitCommands.get() );
 
     // search - "A","B" should be found.
     Map<String,String> args = new HashMap<String, String>();
@@ -240,7 +262,13 @@
 
     // rollback "B"
     RollbackUpdateCommand rbkCmd = new RollbackUpdateCommand();
+    assertEquals( 1, duh2.deleteByIdCommands.get() );
+    assertEquals( 1, duh2.deleteByIdCommandsCumulative.get() );
+    assertEquals( 0, duh2.rollbackCommands.get() );
     updater.rollback(rbkCmd);
+    assertEquals( 0, duh2.deleteByIdCommands.get() );
+    assertEquals( 0, duh2.deleteByIdCommandsCumulative.get() );
+    assertEquals( 1, duh2.rollbackCommands.get() );
     
     // search - "B" should be found.
     assertQ("\"B\" should be found.", req



Mime
View raw message