SOLR-3361: fix "maxNumberOfBackups" to work if backups are triggered on commit

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1329337 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Dyer 2012-04-23 17:12:42 +00:00
parent 9bf158e095
commit 013aebd3ae
4 changed files with 22 additions and 8 deletions

View File

@ -379,6 +379,9 @@ Bug Fixes
* SOLR-3352: eDismax: pf2 should kick in for a query with 2 terms (janhoy)
* SOLR-3361: ReplicationHandler "maxNumberOfBackups" doesn't work if backups are triggered on commit
(James Dyer, Tomas Fernandez Lobbe)
Other Changes
----------------------

View File

@ -994,8 +994,12 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
}
if (snapshoot) {
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);
}

View File

@ -32,7 +32,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>

View File

@ -776,7 +776,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
if(random().nextBoolean()) {
configFile = "solrconfig-master1-keepOneBackup.xml";
addNumberToKeepInRequest = false;
backupKeepParamName = ReplicationHandler.NUMBER_BACKUPS_TO_KEEP_INIT_PARAM;
}
masterJetty.stop();
@ -864,8 +863,16 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
File[] snapDir = new File[2];
String firstBackupTimestamp = null;
for(int i=0 ; i<2 ; i++) {
BackupThread backupThread = new BackupThread(addNumberToKeepInRequest, backupKeepParamName);
BackupThread backupThread = null;
if(!addNumberToKeepInRequest) {
if(random().nextBoolean()) {
masterClient.commit();
} else {
backupThread = new BackupThread(addNumberToKeepInRequest, backupKeepParamName);
backupThread.start();
}
}
File dataDir = new File(master.getDataDir());
@ -890,7 +897,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
waitCnt++;
}
if(backupThread.fail != null) {
if(backupThread!= null && backupThread.fail != null) {
fail(backupThread.fail);
}