You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2016/04/22 01:53:40 UTC
[6/7] lucene-solr:branch_5x: SOLR-8449: Fix the core restore
functionality to allow restoring multiple times on the same core
SOLR-8449: Fix the core restore functionality to allow restoring multiple times on the same core
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/443fd2d2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/443fd2d2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/443fd2d2
Branch: refs/heads/branch_5x
Commit: 443fd2d29a4326a2d483c33bcbfeb7e2f636f250
Parents: 1ce5e53
Author: Varun Thacker <va...@gmail.com>
Authored: Sat Mar 5 13:15:19 2016 +0530
Committer: anshum <an...@apache.org>
Committed: Thu Apr 21 16:04:21 2016 -0700
----------------------------------------------------------------------
solr/CHANGES.txt | 3 ++
.../org/apache/solr/handler/RestoreCore.java | 6 ++-
.../apache/solr/handler/TestRestoreCore.java | 55 +++++++++++---------
3 files changed, 39 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/443fd2d2/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 4df18b3..37558c2 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -122,6 +122,9 @@ Bug Fixes
* SOLR-8779: Fix missing InterruptedException handling in ZkStateReader.java (Varun Thacker)
+* SOLR-8449: Fix the core restore functionality to allow restoring multiple times on the same core
+ (Johannes Brucher, Varun Thacker)
+
Other Changes
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/443fd2d2/solr/core/src/java/org/apache/solr/handler/RestoreCore.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/RestoreCore.java b/solr/core/src/java/org/apache/solr/handler/RestoreCore.java
index ddcad22..4de3ab0 100644
--- a/solr/core/src/java/org/apache/solr/handler/RestoreCore.java
+++ b/solr/core/src/java/org/apache/solr/handler/RestoreCore.java
@@ -19,6 +19,9 @@ package org.apache.solr.handler;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
@@ -57,7 +60,8 @@ public class RestoreCore implements Callable<Boolean> {
private boolean doRestore() throws Exception {
Path backupPath = Paths.get(backupLocation).resolve(backupName);
- String restoreIndexName = "restore." + backupName;
+ SimpleDateFormat dateFormat = new SimpleDateFormat(SnapShooter.DATE_FMT, Locale.ROOT);
+ String restoreIndexName = "restore." + dateFormat.format(new Date());
String restoreIndexPath = core.getDataDir() + restoreIndexName;
Directory restoreIndexDir = null;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/443fd2d2/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java
index d89b217..dcad0e4 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java
@@ -134,36 +134,43 @@ public class TestRestoreCore extends SolrJettyTestBase {
Thread.sleep(1000);
}
- //Modify existing index before we call restore.
- //Delete a few docs
- int numDeletes = TestUtil.nextInt(random(), 1, nDocs);
- for(int i=0; i<numDeletes; i++) {
- masterClient.deleteByQuery("id:" + i);
- }
- masterClient.commit();
-
- //Add a few more
- int moreAdds = TestUtil.nextInt(random(), 1, 100);
- for (int i=0; i<moreAdds; i++) {
- SolrInputDocument doc = new SolrInputDocument();
- doc.addField("id", i + nDocs);
- doc.addField("name", "name = " + (i + nDocs));
- masterClient.add(doc);
- }
- //Purposely not calling commit once in a while. There can be some docs which are not committed
- if (usually()) {
+
+ int numRestoreTests = TestUtil.nextInt(random(), 1, 5);
+
+ for (int attempts=0; attempts<numRestoreTests; attempts++) {
+ //Modify existing index before we call restore.
+
+ //Delete a few docs
+ int numDeletes = TestUtil.nextInt(random(), 1, nDocs);
+ for(int i=0; i<numDeletes; i++) {
+ masterClient.deleteByQuery("id:" + i);
+ }
masterClient.commit();
- }
- TestReplicationHandlerBackup.runBackupCommand(masterJetty, ReplicationHandler.CMD_RESTORE, params);
+ //Add a few more
+ int moreAdds = TestUtil.nextInt(random(), 1, 100);
+ for (int i=0; i<moreAdds; i++) {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", i + nDocs);
+ doc.addField("name", "name = " + (i + nDocs));
+ masterClient.add(doc);
+ }
+ //Purposely not calling commit once in a while. There can be some docs which are not committed
+ if (usually()) {
+ masterClient.commit();
+ }
- while (!fetchRestoreStatus()) {
- Thread.sleep(1000);
+ TestReplicationHandlerBackup.runBackupCommand(masterJetty, ReplicationHandler.CMD_RESTORE, params);
+
+ while (!fetchRestoreStatus()) {
+ Thread.sleep(1000);
+ }
+
+ //See if restore was successful by checking if all the docs are present again
+ verifyDocs(nDocs);
}
- //See if restore was successful by checking if all the docs are present again
- verifyDocs(nDocs);
}
@Test