skoppu22 commented on code in PR #169:
URL: 
https://github.com/apache/cassandra-analytics/pull/169#discussion_r3539142541


##########
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:
   This is copied from getAllNodeSettings, which calculates worst case timeout, 
which is only upper bound. I tried removing gossipInfoFutures.size() from 
multiplication, then in-jvm tests failed because unable to retrieve sstable 
versions before timeout. Perhaps in-jvm specific settings could be problem, but 
don't want to risk the same problem on real cluster. 



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