mirror of https://github.com/apache/lucene.git
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.
This commit is contained in:
parent
7d07fbee5f
commit
9040307787
|
@ -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
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue