SOLR-3531: Allowing configuring maxMergeSizeMB and maxCachedMB when using NRTCachingDirectoryFactory.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1417736 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-12-06 04:39:30 +00:00
parent 6098695cca
commit af20e0b5a6
2 changed files with 21 additions and 1 deletions

View File

@ -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
----------------------

View File

@ -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);
}
}