mlbiscoc commented on code in PR #2916:
URL: https://github.com/apache/solr/pull/2916#discussion_r1893059557


##########
solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java:
##########
@@ -205,54 +214,32 @@ private void fetchClusterStatusForCollOrAlias(
       }
     }
 
-    // TODO use an Iterable to stream the data to the client instead of 
gathering it all in mem
-
-    NamedList<Object> collectionProps = new SimpleOrderedMap<>();
-
-    collectionStream.forEach(
-        clusterStateCollection -> {
-          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);
-          collectionStatus = getCollectionStatus(docCollection, name, 
requestedShards);
-
-          collectionStatus.put("znodeVersion", 
clusterStateCollection.getZNodeVersion());
-          collectionStatus.put(
-              "creationTimeMillis", 
clusterStateCollection.getCreationTime().toEpochMilli());
-
-          if (collectionVsAliases.containsKey(name) && 
!collectionVsAliases.get(name).isEmpty()) {
-            collectionStatus.put("aliases", collectionVsAliases.get(name));
+    MapWriter collectionPropsWriter =
+        ew -> {
+          Iterator<Map<String, Object>> it =
+              collectionStream
+                  .map(
+                      (collectionState) ->
+                          collectionPropsResponse(
+                              collectionState,
+                              collectionVsAliases,
+                              routeKey,
+                              liveNodes,
+                              requestedShards))
+                  .iterator();
+          while (it.hasNext()) {
+            Map<String, Object> props = it.next();
+            props.forEach(
+                (key, value) -> {
+                  try {
+                    ew.put(key, value);
+                  } catch (IOException e) {
+                    throw new RuntimeException(e);
+                  }
+                });

Review Comment:
   I am thinking, if we can change up DocCollection in another PR, we can 
delete all those post processing functions and condense the response to this.
   ```java
   MapWriter collectionPropsWriter =
           ew -> {
             Iterator<DocCollection> it = collectionStream.iterator();
             while (it.hasNext()) {
               DocCollection collState = it.next();
               ew.put(collState.getName(), collState);
             }
           };
   ```



-- 
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]

Reply via email to