Apache Lucene open-source search software
SOLR-11950: Parse CLUSTERSTATUS 'shard' param as comma-delim list
Jason Gerlowski9040307787a0
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 3a6f9054597..702de61cf35 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -203,6 +203,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----------------------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.javaindex 63c1a078fd2..0f159544f0f 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) {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.javaindex 5ffed507598..d9ea73c08da 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)) {