tflobbe commented on code in PR #1318:
URL: https://github.com/apache/solr/pull/1318#discussion_r1090959156


##########
solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java:
##########
@@ -1682,6 +1687,37 @@ public DocCollection getCollectionLive(String coll) {
     }
   }
 
+  /**
+   * fetch the collection that is already cached. This may return a null if it 
is not already cached
+   * This is an optimization to avoid fetching state if it is not modified. 
this is particularly
+   * true for PRS collections where state is rarely modified
+   */
+  private DocCollection fetchCachedCollection(String coll) {
+    String collectionPath = DocCollection.getCollectionPath(coll);
+    DocCollection c = null;
+    ClusterState.CollectionRef ref = clusterState.getCollectionRef(coll);
+    if (ref == null) return null;
+    c = ref.getOrNull();
+    if (c == null) return null;
+    Stat stat = null;
+    try {
+      stat = zkClient.exists(collectionPath, null, false);
+    } catch (Exception e) {
+      return null;
+    }
+    if (stat != null) {
+      if (!c.isModified(stat.getVersion(), stat.getCversion())) {
+        // we have the latest collection state
+        return c;
+      }
+      if (c.isPerReplicaState() && c.getChildNodesVersion() < 
stat.getCversion()) {
+        // only PRS is modified. just fetch it and return the new collection
+        return c.copyWith(PerReplicaStatesFetcher.fetch(collectionPath, 
zkClient, null));
+      }

Review Comment:
   This wouldn't add the updated DocCollection to the cache, right? So any 
future calls to this method will continue on the same path (exists + fetch), 
until some other code path updates the cache, is that right?



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