yifan-c commented on code in PR #169:
URL: 
https://github.com/apache/cassandra-analytics/pull/169#discussion_r3540436078


##########
cassandra-analytics-sidecar-client/src/main/java/org/apache/cassandra/clients/Sidecar.java:
##########
@@ -149,6 +153,79 @@ public static List<CompletableFuture<NodeSettings>> 
allNodeSettings(SidecarClien
                         .collect(Collectors.toList());
     }
 
+    /**
+     * Retrieve gossip info from all nodes on the cluster
+     * @param client Sidecar client
+     * @param instances all Sidecar instances
+     * @return completable futures with GossipInfoResponse
+     */
+    public static List<CompletableFuture<GossipInfoResponse>> 
gossipInfoFromAllNodes(SidecarClient client,
+                                                                               
      Set<SidecarInstance> instances)
+    {
+        return instances.stream()
+                        .map(instance -> client
+                        .gossipInfo(instance)
+                        .exceptionally(throwable -> {
+                            LOGGER.warn(String.format("Failed to retrieve 
gossipinfo from instance=%s",
+                                    instance), throwable);
+                            return null;
+                        }))
+                        .collect(Collectors.toList());
+    }
+
+    /**
+     * Retrieves SSTable versions from all nodes in the cluster via gossip 
info.
+     * This method fetches gossip information from all Sidecar instances and 
extracts
+     * the SSTable versions running on each node.
+     *
+     * @param client Sidecar client
+     * @param instances all Sidecar instances in the cluster
+     * @param maxRetryDelayMillis maximum delay in milliseconds between retries
+     * @param maxRetries maximum number of retry attempts
+     * @return a set of SSTable versions across all nodes in the cluster
+     * @throws RuntimeException if unable to retrieve gossip info from any 
nodes
+     */
+    public static Set<String> getSSTableVersionsFromCluster(SidecarClient 
client,
+                                                             
Set<SidecarInstance> instances,
+                                                             long 
maxRetryDelayMillis,
+                                                             int maxRetries)
+    {
+        LOGGER.debug("Retrieving SSTable versions from cluster via gossip...");
+
+        List<CompletableFuture<GossipInfoResponse>> gossipInfoFutures =
+            gossipInfoFromAllNodes(client, instances);
+
+        // Calculate total timeout
+        final long totalTimeout = maxRetryDelayMillis * maxRetries * 
gossipInfoFutures.size();

Review Comment:
   @lukasz-antoniak had a good point. The calculation is missing the request 
timeout. As a minor correction, the worst scenario is `(maxRetryDelayMillis + 
requestTimeout) * maxRetries`. It is the worst scenario because it calculates 
with the max retry delay; meanwhile, exponential retry is used in the 
production system. 
   
   Serial execution is not expected. The http client executes the requests in 
parallel. The original calculation is bug. It is likely just shaded by the 
overly large value from the additional multiplication. 



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