cypherean commented on code in PR #14250:
URL: https://github.com/apache/pinot/pull/14250#discussion_r2287040699


##########
pinot-controller/src/main/java/org/apache/pinot/controller/util/TableMetadataReader.java:
##########
@@ -127,50 +130,104 @@ private TableReloadJsonResponse 
processSegmentMetadataReloadResponse(
 
   /**
    * This api takes in list of segments for which we need the metadata.
+   * This calls the server to get the metadata for all segments instead of 
making a call per segment.
    */
-  public JsonNode getSegmentsMetadata(String tableNameWithType, List<String> 
columns, Set<String> segmentsToInclude,
+  public JsonNode getSegmentsMetadata(String tableNameWithType, List<String> 
columns, Set<String> segments,
       int timeoutMs)
       throws InvalidConfigException, IOException {
-    return getSegmentsMetadataInternal(tableNameWithType, columns, 
segmentsToInclude, timeoutMs);
+    return getSegmentsMetadataInternal(tableNameWithType, columns, segments, 
timeoutMs);
   }
 
-  private JsonNode getSegmentsMetadataInternal(String tableNameWithType, 
List<String> columns,
-      Set<String> segmentsToInclude, int timeoutMs)
+  /**
+   *   Common helper used by both the new (server-level) and legacy 
(segment-level) endpoints.
+   */
+  private JsonNode fetchAndAggregateMetadata(List<String> urls,
+      BiMap<String, String> endpoints,
+      boolean perSegmentJson,
+      String tableNameWithType,
+      int timeoutMs)
       throws InvalidConfigException, IOException {
-    final Map<String, List<String>> serverToSegmentsMap =
-        _pinotHelixResourceManager.getServerToSegmentsMap(tableNameWithType);
-    BiMap<String, String> endpoints =
-        
_pinotHelixResourceManager.getDataInstanceAdminEndpoints(serverToSegmentsMap.keySet());
-    ServerSegmentMetadataReader serverSegmentMetadataReader =
-        new ServerSegmentMetadataReader(_executor, _connectionManager);
+    CompletionServiceHelper cs = new CompletionServiceHelper(_executor, 
_connectionManager, endpoints);
+    CompletionServiceHelper.CompletionServiceResponse resp =
+        cs.doMultiGetRequest(urls, tableNameWithType, perSegmentJson, 
timeoutMs);
+    // all requests will fail if new server endpoint is not available
+    if (resp._failedResponseCount == urls.size()) {

Review Comment:
   Checking for failure > 0 now and throws a runtime exception which is caught 
and ignored to fallback to legacy



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