dsmiley commented on code in PR #2916:
URL: https://github.com/apache/solr/pull/2916#discussion_r1890699859
##########
solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java:
##########
@@ -368,4 +341,77 @@ public static Map<String, Object>
postProcessCollectionJSON(Map<String, Object>
collection.put("health", Health.combine(healthStates).toString());
return collection;
}
+
+ private class SolrCollectionProperiesIterator implements
Iterator<NamedList<Object>> {
+
+ final Iterator<DocCollection> it;
+ Map<String, List<String>> collectionVsAliases;
+ String routeKey;
+ List<String> liveNodes;
+ String shard;
+
+ public SolrCollectionProperiesIterator(
+ Iterator<DocCollection> it,
+ Map<String, List<String>> collectionVsAliases,
+ String routeKey,
+ List<String> liveNodes,
+ String shard) {
+ this.it = it;
+ this.collectionVsAliases = collectionVsAliases;
+ this.routeKey = routeKey;
+ this.liveNodes = liveNodes;
+ this.shard = shard;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public NamedList<Object> next() {
+ NamedList<Object> collectionProps = new SimpleOrderedMap<>();
+ DocCollection clusterStateCollection = it.next();
+ Map<String, Object> collectionStatus;
+ String name = clusterStateCollection.getName();
+
+ Set<String> requestedShards = new HashSet<>();
+ if (routeKey != null) {
+ DocRouter router = clusterStateCollection.getRouter();
+ Collection<Slice> slices = router.getSearchSlices(routeKey, null,
clusterStateCollection);
+ for (Slice slice : slices) {
+ requestedShards.add(slice.getName());
+ }
+ }
+ if (shard != null) {
+ String[] paramShards = shard.split(",");
+ requestedShards.addAll(Arrays.asList(paramShards));
+ }
Review Comment:
ideally this is done up front; not per iteration
##########
solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java:
##########
@@ -368,4 +341,77 @@ public static Map<String, Object>
postProcessCollectionJSON(Map<String, Object>
collection.put("health", Health.combine(healthStates).toString());
return collection;
}
+
+ private class SolrCollectionProperiesIterator implements
Iterator<NamedList<Object>> {
Review Comment:
I was hoping we wouldn't need a custom Iterator. We do need a method that
takes in DocCollection (and some other context that is the same across
collections) and returns a NamedList. With such a method, we can call it via
streamOfDocCollection.map(collState -> theMethod(collState, routeKey,
liveNodes, etc.).iterator()
##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java:
##########
@@ -140,11 +139,11 @@ private ClusterState fetchClusterState(SolrClient client)
liveNodesTimestamp = System.nanoTime();
}
- var collectionsNl = (NamedList<Map<String, Object>>)
cluster.get("collections");
+ var collectionsNl = (Map<String, Map<String, Object>>)
cluster.get("collections");
Review Comment:
this var name is no longer appropriate. Should be collectionsMap (and we
assume by name).
##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java:
##########
@@ -185,7 +184,9 @@ private DocCollection fetchCollectionState(SolrClient
client, String collection)
SimpleOrderedMap<?> cluster =
submitClusterStateRequest(client, collection,
ClusterStateRequestType.FETCH_COLLECTION);
- var collStateMap = (Map<String, Object>)
cluster.findRecursive("collections", collection);
+ var collState = (Map<String, Object>) cluster.findRecursive("collections");
Review Comment:
so findRecursive can only resolve collections and not Map? Seems worth a
small enhancement to do so but I understand if you don't bother or defer.
##########
solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java:
##########
@@ -368,4 +341,77 @@ public static Map<String, Object>
postProcessCollectionJSON(Map<String, Object>
collection.put("health", Health.combine(healthStates).toString());
return collection;
}
+
+ private class SolrCollectionProperiesIterator implements
Iterator<NamedList<Object>> {
+
+ final Iterator<DocCollection> it;
+ Map<String, List<String>> collectionVsAliases;
+ String routeKey;
+ List<String> liveNodes;
+ String shard;
+
+ public SolrCollectionProperiesIterator(
+ Iterator<DocCollection> it,
+ Map<String, List<String>> collectionVsAliases,
+ String routeKey,
+ List<String> liveNodes,
+ String shard) {
+ this.it = it;
+ this.collectionVsAliases = collectionVsAliases;
+ this.routeKey = routeKey;
+ this.liveNodes = liveNodes;
+ this.shard = shard;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public NamedList<Object> next() {
+ NamedList<Object> collectionProps = new SimpleOrderedMap<>();
+ DocCollection clusterStateCollection = it.next();
+ Map<String, Object> collectionStatus;
+ String name = clusterStateCollection.getName();
+
+ Set<String> requestedShards = new HashSet<>();
+ if (routeKey != null) {
+ DocRouter router = clusterStateCollection.getRouter();
+ Collection<Slice> slices = router.getSearchSlices(routeKey, null,
clusterStateCollection);
+ for (Slice slice : slices) {
+ requestedShards.add(slice.getName());
+ }
+ }
+ if (shard != null) {
+ String[] paramShards = shard.split(",");
+ requestedShards.addAll(Arrays.asList(paramShards));
+ }
+
+ byte[] bytes = Utils.toJSON(clusterStateCollection);
+ @SuppressWarnings("unchecked")
+ Map<String, Object> docCollection = (Map<String, Object>)
Utils.fromJSON(bytes);
Review Comment:
why round-trip this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]