You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jd...@apache.org on 2012/04/23 19:32:22 UTC

svn commit: r1329351 - in /lucene/dev/branches/lucene_solr_3_6/solr: ./ core/src/java/org/apache/solr/handler/ core/src/test-files/solr/conf/ core/src/test/org/apache/solr/handler/

Author: jdyer
Date: Mon Apr 23 17:32:21 2012
New Revision: 1329351

URL: http://svn.apache.org/viewvc?rev=1329351&view=rev
Log:
SOLR-3361: fix "maxNumberOfBackups" to work if backups are triggered on commit

Modified:
    lucene/dev/branches/lucene_solr_3_6/solr/   (props changed)
    lucene/dev/branches/lucene_solr_3_6/solr/CHANGES.txt
    lucene/dev/branches/lucene_solr_3_6/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
    lucene/dev/branches/lucene_solr_3_6/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml
    lucene/dev/branches/lucene_solr_3_6/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java

Modified: lucene/dev/branches/lucene_solr_3_6/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_3_6/solr/CHANGES.txt?rev=1329351&r1=1329350&r2=1329351&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_3_6/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_3_6/solr/CHANGES.txt Mon Apr 23 17:32:21 2012
@@ -27,6 +27,9 @@ Bug Fixes:
 * LUCENE-3969: Throw IAE on bad arguments that could cause confusing errors in
   PatternTokenizer. CommonGrams populates PositionLengthAttribute correctly.
   (Uwe Schindler, Mike McCandless, Robert Muir)
+  
+* SOLR-3361: ReplicationHandler "maxNumberOfBackups" doesn't work if backups are triggered on commit
+  (James Dyer, Tomas Fernandez Lobbe)
 
 ==================  3.6.0  ==================
 More information about this release, including any errata related to the 

Modified: lucene/dev/branches/lucene_solr_3_6/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_3_6/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java?rev=1329351&r1=1329350&r2=1329351&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_3_6/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java (original)
+++ lucene/dev/branches/lucene_solr_3_6/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java Mon Apr 23 17:32:21 2012
@@ -983,9 +983,13 @@ public class ReplicationHandler extends 
           ***/
         }
         if (snapshoot) {
-          try {
+          try {            
+            int numberToKeep = numberBackupsToKeep;
+            if (numberToKeep < 1) {
+              numberToKeep = Integer.MAX_VALUE;
+            }            
             SnapShooter snapShooter = new SnapShooter(core, null);
-            snapShooter.createSnapAsync(currentCommitPoint, ReplicationHandler.this);
+            snapShooter.createSnapAsync(currentCommitPoint, numberToKeep, ReplicationHandler.this);
           } catch (Exception e) {
             LOG.error("Exception while snapshooting", e);
           }

Modified: lucene/dev/branches/lucene_solr_3_6/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_3_6/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml?rev=1329351&r1=1329350&r2=1329351&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_3_6/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml (original)
+++ lucene/dev/branches/lucene_solr_3_6/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml Mon Apr 23 17:32:21 2012
@@ -40,7 +40,7 @@
 
   <requestHandler name="/replication" class="solr.ReplicationHandler">
     <lst name="master">
-      <str name="replicateAfter">commit</str>
+      <str name="backupAfter">commit</str>
       <str name="confFiles">schema-replication2.xml:schema.xml</str>
     </lst>    
     <str name="maxNumberOfBackups">1</str>

Modified: lucene/dev/branches/lucene_solr_3_6/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_3_6/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1329351&r1=1329350&r2=1329351&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_3_6/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/lucene_solr_3_6/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Mon Apr 23 17:32:21 2012
@@ -626,7 +626,6 @@ public class TestReplicationHandler exte
     if(random.nextBoolean()) {
       configFile = "solrconfig-master1-keepOneBackup.xml";
       addNumberToKeepInRequest = false;
-      backupKeepParamName = ReplicationHandler.NUMBER_BACKUPS_TO_KEEP_INIT_PARAM;
     }
     masterJetty.stop();
     master.copyConfigFile(CONF_DIR + configFile, 
@@ -713,8 +712,16 @@ public class TestReplicationHandler exte
     File[] snapDir = new File[2];
     String firstBackupTimestamp = null;
     for(int i=0 ; i<2 ; i++) {
-      BackupThread backupThread = new BackupThread(addNumberToKeepInRequest, backupKeepParamName);
-      backupThread.start();
+      BackupThread backupThread = null;
+      if(!addNumberToKeepInRequest) {
+        if(random.nextBoolean()) {
+          masterClient.commit();
+        } else {
+          backupThread = new BackupThread(addNumberToKeepInRequest, backupKeepParamName);
+          backupThread.start();
+        }
+      }
+      
       
       File dataDir = new File(master.getDataDir());
       
@@ -739,7 +746,7 @@ public class TestReplicationHandler exte
         waitCnt++;
       }
       
-      if(backupThread.fail != null) {
+      if(backupThread!= null && backupThread.fail != null) {
         fail(backupThread.fail);
       }