diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 1cc811449f5..2a8558e9a9a 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -109,6 +109,9 @@ New Features * SOLR-4114: Allow creating more than one shard per instance with the Collection API. (Per Steffensen, Mark Miller) +* SOLR-3531: Allowing configuring maxMergeSizeMB and maxCachedMB when + using NRTCachingDirectoryFactory. (Andy Laird via Mark Miller) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/core/NRTCachingDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/NRTCachingDirectoryFactory.java index 957d3a26361..f97c2ee2925 100644 --- a/solr/core/src/java/org/apache/solr/core/NRTCachingDirectoryFactory.java +++ b/solr/core/src/java/org/apache/solr/core/NRTCachingDirectoryFactory.java @@ -23,15 +23,32 @@ import java.io.IOException; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; import org.apache.lucene.store.NRTCachingDirectory; +import org.apache.solr.common.params.SolrParams; +import org.apache.solr.common.util.NamedList; /** * Factory to instantiate {@link org.apache.lucene.store.NRTCachingDirectory} */ public class NRTCachingDirectoryFactory extends StandardDirectoryFactory { + private double maxMergeSizeMB; + private double maxCachedMB; + + @Override + public void init(NamedList args) { + SolrParams params = SolrParams.toSolrParams(args); + maxMergeSizeMB = params.getDouble("maxMergeSizeMB", 4); + if (maxMergeSizeMB <= 0){ + throw new IllegalArgumentException("maxMergeSizeMB must be greater than 0"); + } + maxCachedMB = params.getDouble("maxCachedMB", 48); + if (maxCachedMB <= 0){ + throw new IllegalArgumentException("maxCachedMB must be greater than 0"); + } + } @Override protected Directory create(String path) throws IOException { - return new NRTCachingDirectory(FSDirectory.open(new File(path)), 4, 48); + return new NRTCachingDirectory(FSDirectory.open(new File(path)), maxMergeSizeMB, maxCachedMB); } }