Skip to content

Commit

Permalink
SolrJ: CloudSolrClient, HTTP StateProvider: Use EnvUtils to customize…
Browse files Browse the repository at this point in the history
… a cache timeout (#2629)

New "solr.solrj.cache.timeout.sec" setting which will affect HttpClusterStateProvider caching of liveNodes and aliases.
  • Loading branch information
aparnasuresh85 authored Aug 13, 2024
1 parent 8ddc3be commit 90dc8d9
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -55,7 +56,8 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
volatile Map<String, Map<String, String>> 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<String> solrUrls) throws Exception {
for (String solrUrl : solrUrls) {
Expand Down Expand Up @@ -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 {}

Expand Down

0 comments on commit 90dc8d9

Please sign in to comment.