lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ans...@apache.org
Subject lucene-solr git commit: SOLR-8765: Fix CollectionAdminRequest.SplitShard to accept requests without the 'shard' parameter
Date Fri, 11 Mar 2016 01:11:31 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 8fe11a06c -> bc4115864


SOLR-8765: Fix CollectionAdminRequest.SplitShard to accept requests without the 'shard' 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/bc411586
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/bc411586
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/bc411586

Branch: refs/heads/branch_6x
Commit: bc41158648fc031cc1fe7b07ed62f5f140854f59
Parents: 8fe11a0
Author: anshum <anshum@apache.org>
Authored: Thu Mar 10 13:59:37 2016 -0800
Committer: Anshum Gupta <anshum@apache.org>
Committed: Thu Mar 10 17:06:35 2016 -0800

----------------------------------------------------------------------
 .../solr/handler/admin/CollectionsHandler.java  |  2 +-
 .../solrj/request/CollectionAdminRequest.java   | 36 +++++++++++++-------
 .../common/params/CollectionAdminParams.java    |  2 ++
 3 files changed, 26 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bc411586/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index 06968c3..b4d0a1d 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -454,7 +454,7 @@ public class CollectionsHandler extends RequestHandlerBase {
         String splitKey = req.getParams().get("split.key");
 
         if (splitKey == null && shard == null) {
-          throw new SolrException(ErrorCode.BAD_REQUEST, "Missing required parameter: shard");
+          throw new SolrException(ErrorCode.BAD_REQUEST, "At least one of shard, or split.key
should be specified.");
         }
         if (splitKey != null && shard != null) {
           throw new SolrException(ErrorCode.BAD_REQUEST,

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bc411586/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 76eb19f..0c25e09 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
@@ -616,27 +616,30 @@ public abstract class CollectionAdminRequest<T extends CollectionAdminResponse>
   /**
    * Returns a SolrRequest to split a shard in a collection
    */
-  public static SplitShard splitShard(String collection, String shard) {
-    return new SplitShard(collection, shard);
+  public static SplitShard splitShard(String collection) {
+    return new SplitShard(collection);
   }
 
   // SPLITSHARD request
-  public static class SplitShard extends AsyncShardSpecificAdminRequest {
+  public static class SplitShard extends AsyncCollectionAdminRequest {
+    protected String collection;
     protected String ranges;
     protected String splitKey;
+    protected String shard;
 
     private Properties properties;
 
-    private SplitShard(String collection, String shard) {
-      super(CollectionAction.SPLITSHARD, collection, shard);
+    private SplitShard(String collection) {
+      super(CollectionAction.SPLITSHARD);
+      this.collection = collection;
     }
 
     /**
-     * @deprecated Use {@link #splitShard(String, String)}
+     * @deprecated Use {@link #splitShard(String)}
      */
     @Deprecated
     public SplitShard() {
-      super(CollectionAction.SPLITSHARD, null, null);
+      super(CollectionAction.SPLITSHARD);
     }
 
     public SplitShard setRanges(String ranges) { this.ranges = ranges; return this; }
@@ -660,15 +663,12 @@ public abstract class CollectionAdminRequest<T extends CollectionAdminResponse>
       return this;
     }
 
-    @Override
     @Deprecated
     public SplitShard setCollectionName(String collection) {
       this.collection = collection;
       return this;
     }
 
-    @Override
-    @Deprecated
     public SplitShard setShardName(String shard) {
       this.shard = shard;
       return this;
@@ -684,10 +684,20 @@ public abstract class CollectionAdminRequest<T extends CollectionAdminResponse>
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
-      params.set( "ranges", ranges);
 
-      if(splitKey != null)
-        params.set("split.key", this.splitKey);
+      if(this.collection == null) {
+        throw new IllegalArgumentException("You must set collection name for this request.");
+      }
+
+      params.set(CollectionAdminParams.COLLECTION, collection);
+
+      if (this.shard == null && this.splitKey == null) {
+        throw new IllegalArgumentException("You must set shardname OR splitkey for this request.");
+      }
+
+      params.set("shard", shard);
+      params.set("split.key", this.splitKey);
+      params.set( "ranges", ranges);
 
       if(properties != null) {
         addProperties(params, properties);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bc411586/solr/solrj/src/java/org/apache/solr/common/params/CollectionAdminParams.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/CollectionAdminParams.java
b/solr/solrj/src/java/org/apache/solr/common/params/CollectionAdminParams.java
index b9bf717..e817dd9 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/CollectionAdminParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/CollectionAdminParams.java
@@ -21,4 +21,6 @@ public abstract class CollectionAdminParams {
   /* Param used by DELETESTATUS call to clear all stored responses */
   public static final String FLUSH = "flush";
 
+  public static final String COLLECTION = "collection";
+
 }


Mime
View raw message