From 4381018b77f019ce2c579240538177b546ff3d86 Mon Sep 17 00:00:00 2001 From: Varun Thacker Date: Sat, 5 Mar 2016 13:15:19 +0530 Subject: [PATCH] SOLR-8449: Fix the core restore functionality to allow restoring multiple times on the same core --- solr/CHANGES.txt | 3 + .../org/apache/solr/handler/RestoreCore.java | 6 +- .../apache/solr/handler/TestRestoreCore.java | 57 +++++++++++-------- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 60d3f4d2003..813a0b79f07 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -267,6 +267,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) + Optimizations ---------------------- * SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been 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 a6c1da90ec8..9949d3fcf85 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; @@ -55,7 +58,8 @@ public class RestoreCore implements Callable { 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; 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 b219a8dbb0d..1218783d7b2 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java +++ b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java @@ -138,36 +138,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