You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ge...@apache.org on 2018/02/13 12:06:00 UTC
lucene-solr:branch_7x: SOLR-11950: Parse CLUSTERSTATUS 'shard' param
as comma-delim list
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x c87b58cf7 -> 7f651bd71
SOLR-11950: Parse CLUSTERSTATUS 'shard' param as comma-delim list
The documentation for the 'shard' parameter on CLUSTERSTATUS requests,
indicates that users should be able to provide a comma-separated list
of shards they are interested in. However, prior to this commit the
parameter value was parsed as a single shard name, causing requests
with more than one shard to return as a 400.
This commit changes this behavior to correctly parse the param value.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/7f651bd7
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7f651bd7
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7f651bd7
Branch: refs/heads/branch_7x
Commit: 7f651bd713dbc9f4a390b74009c444ba5e56a0c9
Parents: c87b58c
Author: Jason Gerlowski <ge...@apache.org>
Authored: Tue Feb 13 06:54:39 2018 -0500
Committer: Jason Gerlowski <ge...@apache.org>
Committed: Tue Feb 13 06:59:47 2018 -0500
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
.../solr/handler/admin/ClusterStatus.java | 5 +++-
.../api/collections/TestCollectionAPI.java | 24 ++++++++++++++++++++
3 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7f651bd7/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 5dd6e5f..466bb25 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -183,6 +183,8 @@ Bug Fixes
* SOLR-11898: ConcurrentModificationException when calling org.apache.solr.core.SolrInfoBean.getMetricsSnapshot
(Jeff Miller via Erick Erickson)
+* SOLR-11950: Allow CLUSTERSTATUS "shard" parameter to accept comma (,) delimited list (Chris Ulicny via Jason Gerlowski)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7f651bd7/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java b/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
index 63c1a07..0f15954 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
@@ -115,7 +115,10 @@ public class ClusterStatus {
}
}
if (shard != null) {
- requestedShards.add(shard);
+ String[] paramShards = shard.split(",");
+ for(String paramShard : paramShards){
+ requestedShards.add(paramShard);
+ }
}
if (clusterStateCollection.getStateFormat() > 1) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7f651bd7/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
index 5ffed50..d9ea73c 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java
@@ -83,6 +83,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
clusterStatusNoCollection();
clusterStatusWithCollection();
clusterStatusWithCollectionAndShard();
+ clusterStatusWithCollectionAndMultipleShards();
clusterStatusWithRouteKey();
clusterStatusAliasTest();
clusterStatusRolesTest();
@@ -122,6 +123,29 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
}
}
+ private void clusterStatusWithCollectionAndMultipleShards() throws IOException, SolrServerException {
+ try (CloudSolrClient client = createCloudClient(null)) {
+ final CollectionAdminRequest.ClusterStatus request = new CollectionAdminRequest.ClusterStatus();
+ request.setCollectionName(COLLECTION_NAME);
+ request.setShardName(SHARD1 + "," + SHARD2);
+
+ NamedList<Object> rsp = request.process(client).getResponse();
+ NamedList<Object> cluster = (NamedList<Object>) rsp.get("cluster");
+ assertNotNull("Cluster state should not be null", cluster);
+ NamedList<Object> collections = (NamedList<Object>) cluster.get("collections");
+ assertNotNull("Collections should not be null in cluster state", collections);
+ assertNotNull(collections.get(COLLECTION_NAME));
+ assertEquals(1, collections.size());
+ Map<String, Object> collection = (Map<String, Object>) collections.get(COLLECTION_NAME);
+ Map<String, Object> shardStatus = (Map<String, Object>) collection.get("shards");
+ assertEquals(2, shardStatus.size());
+ Map<String, Object> firstSelectedShardStatus = (Map<String, Object>) shardStatus.get(SHARD1);
+ assertNotNull(firstSelectedShardStatus);
+ Map<String, Object> secondSelectedShardStatus = (Map<String, Object>) shardStatus.get(SHARD2);
+ assertNotNull(secondSelectedShardStatus);
+ }
+ }
+
private void listCollection() throws IOException, SolrServerException {
try (CloudSolrClient client = createCloudClient(null)) {