lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject [13/36] lucene-solr:jira/http2: SOLR-12597: Migrate API should fail requests that do not specify split.key parameter
Date Tue, 31 Jul 2018 02:32:29 GMT
SOLR-12597: Migrate API should fail requests that do not specify split.key parameter


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/3119fbb9
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/3119fbb9
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/3119fbb9

Branch: refs/heads/jira/http2
Commit: 3119fbb947a5ced79441dc73bcca13367afcf5f6
Parents: dfb18a6
Author: Shalin Shekhar Mangar <shalin@apache.org>
Authored: Fri Jul 27 11:53:53 2018 +0530
Committer: Shalin Shekhar Mangar <shalin@apache.org>
Committed: Fri Jul 27 11:53:53 2018 +0530

----------------------------------------------------------------------
 solr/CHANGES.txt                                  |  2 ++
 .../solr/cloud/api/collections/MigrateCmd.java    |  5 +++++
 .../apache/solr/cloud/MigrateRouteKeyTest.java    | 18 ++++++++++++++++++
 .../solrj/request/CollectionAdminRequest.java     |  3 +--
 4 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3119fbb9/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6c43f14..c837eb7 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -173,6 +173,8 @@ Bug Fixes
 
 * SOLR-12576: Update ref guide for additional information displayed in cloud view (Erick
Erickson)
 
+* SOLR-12597: Migrate API should fail requests that do not specify split.key parameter (shalin)
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3119fbb9/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateCmd.java
index 882c7ef..59b7218 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateCmd.java
@@ -91,6 +91,11 @@ public class MigrateCmd implements OverseerCollectionMessageHandler.Cmd
{
     if (!(targetCollection.getRouter() instanceof CompositeIdRouter)) {
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Target collection must
use a compositeId router");
     }
+
+    if (splitKey == null || splitKey.trim().length() == 0)  {
+      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "The split.key cannot
be null or empty");
+    }
+
     CompositeIdRouter sourceRouter = (CompositeIdRouter) sourceCollection.getRouter();
     CompositeIdRouter targetRouter = (CompositeIdRouter) targetCollection.getRouter();
     Collection<Slice> sourceSlices = sourceRouter.getSearchSlicesSingle(splitKey, null,
sourceCollection);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3119fbb9/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java b/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java
index 57ff0b6..5e17706 100644
--- a/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java
@@ -85,6 +85,24 @@ public class MigrateRouteKeyTest extends SolrCloudTestCase {
   }
 
   @Test
+  public void testMissingSplitKey() throws Exception  {
+    String sourceCollection = "testMissingSplitKey-source";
+    CollectionAdminRequest.createCollection(sourceCollection, "conf", 1, 1)
+        .process(cluster.getSolrClient());
+    String targetCollection = "testMissingSplitKey-target";
+    CollectionAdminRequest.createCollection(targetCollection, "conf", 1, 1)
+        .process(cluster.getSolrClient());
+
+    HttpSolrClient.RemoteSolrException remoteSolrException = expectThrows(HttpSolrClient.RemoteSolrException.class,
+        "Expected an exception in case split.key is not specified", () -> {
+          CollectionAdminRequest.migrateData(sourceCollection, targetCollection, "")
+              .setForwardTimeout(45)
+              .process(cluster.getSolrClient());
+        });
+    assertTrue(remoteSolrException.getMessage().contains("split.key cannot be null or empty"));
+  }
+
+  @Test
   public void multipleShardMigrateTest() throws Exception  {
 
     CollectionAdminRequest.createCollection("sourceCollection", "conf", 2, 1).process(cluster.getSolrClient());

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3119fbb9/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
index 1f5fdd2..301cbc8 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
@@ -1946,8 +1946,7 @@ public abstract class CollectionAdminRequest<T extends CollectionAdminResponse>
       super(CollectionAction.MIGRATE);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
       this.targetCollection = checkNotNull("targetCollection", targetCollection);
-      // TODO: inconsistent with "split.key"
-      this.splitKey = checkNotNull("splitKey", splitKey);
+      this.splitKey = checkNotNull("split.key", splitKey);
     }
 
     public String getCollectionName() {


Mime
View raw message