You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2019/08/19 19:50:02 UTC

[lucene-solr] branch master updated: SOLR-13650: cache reload listener

This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new 6eae96c  SOLR-13650: cache reload listener
6eae96c is described below

commit 6eae96c34c82951bcb3f44c8f4baaa6f361fc7a2
Author: noble <no...@apache.org>
AuthorDate: Tue Aug 20 05:49:46 2019 +1000

    SOLR-13650: cache reload listener
---
 .../core/src/java/org/apache/solr/search/SolrCacheHolder.java | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/solr/core/src/java/org/apache/solr/search/SolrCacheHolder.java b/solr/core/src/java/org/apache/solr/search/SolrCacheHolder.java
index 9f1e124..266b743 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrCacheHolder.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrCacheHolder.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import java.util.Set;
 
 import com.codahale.metrics.MetricRegistry;
+import org.apache.solr.core.RuntimeLib;
 import org.apache.solr.metrics.SolrMetrics;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -38,6 +39,16 @@ public class SolrCacheHolder<K, V> implements SolrCache<K,V> {
   public SolrCacheHolder(CacheConfig.CacheInfo cacheInfo) {
     this.info = cacheInfo;
     this.delegate = cacheInfo.cache;
+    if(info.pkg != null){
+      info.core.addPackageListener(info.pkg, lib -> reloadCache(lib));
+    }
+  }
+
+  private void reloadCache(RuntimeLib lib) {
+    if (lib.getZnodeVersion() > info.znodeVersion) {
+      info = new CacheConfig.CacheInfo(info.cfg, info.core);
+      delegate = info.cache;
+    }
   }
 
   public int size() {