From 90dc8d994c25599f1d43fb7e602967ee21a081ca Mon Sep 17 00:00:00 2001 From: aparnasuresh85 Date: Tue, 13 Aug 2024 11:54:54 -0400 Subject: [PATCH] SolrJ: CloudSolrClient, HTTP StateProvider: Use EnvUtils to customize a cache timeout (#2629) New "solr.solrj.cache.timeout.sec" setting which will affect HttpClusterStateProvider caching of liveNodes and aliases. --- .../client/solrj/impl/BaseHttpClusterStateProvider.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java index 2555a0cba4f..d9186057ef7 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java @@ -39,6 +39,7 @@ import org.apache.solr.common.cloud.DocCollection; import org.apache.solr.common.cloud.PerReplicaStates; import org.apache.solr.common.params.ModifiableSolrParams; +import org.apache.solr.common.util.EnvUtils; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SimpleOrderedMap; import org.apache.solr.common.util.Utils; @@ -55,7 +56,8 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid volatile Map> aliasProperties; long aliasesTimestamp = 0; - private int cacheTimeout = 5; // the liveNodes and aliases cache will be invalidated after 5 secs + // the liveNodes and aliases cache will be invalidated after 5 secs + private int cacheTimeout = EnvUtils.getPropertyAsInteger("solr.solrj.cache.timeout.sec", 5); public void init(List solrUrls) throws Exception { for (String solrUrl : solrUrls) { @@ -411,10 +413,6 @@ public int getCacheTimeout() { return cacheTimeout; } - public void setCacheTimeout(int cacheTimeout) { - this.cacheTimeout = cacheTimeout; - } - // This exception is not meant to escape this class it should be caught and wrapped. private static class NotACollectionException extends Exception {}