You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "yifan-c (via GitHub)" <gi...@apache.org> on 2023/06/27 22:16:40 UTC

[GitHub] [cassandra-analytics] yifan-c commented on a diff in pull request #9: [CASSANDRA-18633] Added Caching of Node Settings to Improve Efficiency

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


##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/CassandraClusterInfo.java:
##########
@@ -338,11 +339,23 @@ public String getVersionFromFeature()
 
     public String getVersionFromSidecar()
     {
-        LOGGER.info("Getting Cassandra versions from all nodes");
-        List<NodeSettings> allNodeSettings = Sidecar.allNodeSettingsBlocking(conf,
-                                                                             cassandraContext.getSidecarClient(),
-                                                                             cassandraContext.clusterConfig);
-        return getLowestVersion(allNodeSettings);
+        List<NodeSettings> currentAllNodeSettings = allNodeSettings;
+        if (currentAllNodeSettings != null)
+        {
+            return getLowestVersion(currentAllNodeSettings);
+        }
+
+        synchronized (this)
+        {
+            if (allNodeSettings == null)
+            {
+                LOGGER.info("Getting Cassandra versions from all nodes");
+                allNodeSettings = Sidecar.allNodeSettingsBlocking(conf,
+                                                                  cassandraContext.getSidecarClient(),
+                                                                  cassandraContext.clusterConfig);
+            }
+            return getLowestVersion(allNodeSettings);

Review Comment:
   I think this line could be moved out of the critical section. 
   And further more, it can combine with line#345 and making it the classic double checked locking pattern...



-- 
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: commits-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org