Skip to content

Apache Lucene open-source search software

[logging] log actual size of transient core cache

Mike Drobadb829cf3589
diff --git a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java
index 84dd4e7aaad..192a29a7f02 100644
--- a/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java
+++ b/solr/core/src/java/org/apache/solr/core/TransientSolrCoreCacheDefault.java
@@ -76,14 +76,16 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
}
}
- log.info("Allocating transient cache for {} transient cores", cacheSize);
// it's possible for cache
if (cacheSize < 0) { // Trap old flag
cacheSize = Integer.MAX_VALUE;
}
+
// Now don't allow ridiculous allocations here, if the size is > 1,000, we'll just deal with
// adding cores as they're opened. This blows up with the marker value of -1.
- transientCores = new LinkedHashMap<String, SolrCore>(Math.min(cacheSize, 1000), 0.75f, true) {
+ int actualCacheSize = Math.min(cacheSize, 1000);
+ log.info("Allocating transient cache for {} transient cores", actualCacheSize);
+ transientCores = new LinkedHashMap<>(actualCacheSize, 0.75f, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<String, SolrCore> eldest) {
if (size() > cacheSize) {
@@ -100,7 +102,7 @@ public class TransientSolrCoreCacheDefault extends TransientSolrCoreCache {
@Override
public Collection<SolrCore> prepareForShutdown() {
- // Returna copy of the values
+ // Return a copy of the values
List<SolrCore> ret = new ArrayList(transientCores.values());
transientCores.clear();
return ret;