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 06968c38148..b4d0a1d06d9 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, 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 76eb19f7640..0c25e09b5cd 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 /** * 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 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 @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); 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 b9bf717663f..e817dd9664d 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"; + }