diff --git a/src/java/org/apache/solr/core/DirectoryFactory.java b/src/java/org/apache/solr/core/DirectoryFactory.java new file mode 100755 index 00000000000..2d93765fea7 --- /dev/null +++ b/src/java/org/apache/solr/core/DirectoryFactory.java @@ -0,0 +1,26 @@ +package org.apache.solr.core; + +import java.io.IOException; + +import org.apache.lucene.store.Directory; +import org.apache.solr.common.util.NamedList; +import org.apache.solr.util.plugin.NamedListInitializedPlugin; + +/** + * Provides access to a Directory implementation. + * + */ +public abstract class DirectoryFactory implements NamedListInitializedPlugin { + + /** + * Opens a Lucene directory + * + * @return + * @throws IOException + */ + public abstract Directory open(String path) throws IOException; + + + public void init(NamedList args) { + } +} diff --git a/src/java/org/apache/solr/core/StandardDirectoryFactory.java b/src/java/org/apache/solr/core/StandardDirectoryFactory.java new file mode 100755 index 00000000000..42dd12ad06a --- /dev/null +++ b/src/java/org/apache/solr/core/StandardDirectoryFactory.java @@ -0,0 +1,23 @@ +package org.apache.solr.core; + +import java.io.IOException; + +import org.apache.lucene.store.Directory; +import org.apache.lucene.store.FSDirectory; +import org.apache.lucene.store.NIOFSDirectory; +import org.apache.lucene.util.Constants; + +/** + * Directory provider which mimics original Solr FSDirectory based behavior. + * + */ +public class StandardDirectoryFactory extends DirectoryFactory { + + public Directory open(String path) throws IOException { + if (!Constants.WINDOWS) { + return NIOFSDirectory.getDirectory(path); + } + + return FSDirectory.getDirectory(path); + } +} diff --git a/src/test/org/apache/solr/core/AlternateDirectoryTest.java b/src/test/org/apache/solr/core/AlternateDirectoryTest.java new file mode 100755 index 00000000000..39fe7b8158f --- /dev/null +++ b/src/test/org/apache/solr/core/AlternateDirectoryTest.java @@ -0,0 +1,36 @@ +package org.apache.solr.core; + +import java.io.IOException; +import org.apache.lucene.store.FSDirectory; +import org.apache.solr.util.AbstractSolrTestCase; + +public class AlternateDirectoryTest extends AbstractSolrTestCase { + + public String getSchemaFile() { + return "schema.xml"; + } + + public String getSolrConfigFile() { + return "solrconfig-altdirectory.xml"; + } + + /** + * Simple test to ensure that alternate IndexReaderFactory is being used. + * + * @throws Exception + */ + public void testAltDirectoryUsed() throws Exception { + assertTrue(TestFSDirectoryFactory.openCalled); + } + + static public class TestFSDirectoryFactory extends DirectoryFactory { + public static boolean openCalled = false; + + public FSDirectory open(String path) throws IOException { + openCalled = true; + return FSDirectory.getDirectory(path); + } + + } + +} diff --git a/src/test/test-files/solr/conf/solrconfig-altdirectory.xml b/src/test/test-files/solr/conf/solrconfig-altdirectory.xml new file mode 100755 index 00000000000..04b2f433a1e --- /dev/null +++ b/src/test/test-files/solr/conf/solrconfig-altdirectory.xml @@ -0,0 +1,420 @@ + + + + + + + + + + + + ${solr.data.dir:./solr/data} + + + + + false + 10 + + + + 32 + 2147483647 + 10000 + 1000 + 10000 + + + false + + + org.apache.lucene.index.LogByteSizeMergePolicy + + + org.apache.lucene.index.ConcurrentMergeScheduler + + 1000 + 10000 + + single + + + + + false + 10 + 32 + 2147483647 + 10000 + + true + + + + + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + + true + + + + + true + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + 0.01 + + text^0.5 features_t^1.0 subject^1.4 title_stemmed^2.0 + + + text^0.2 features_t^1.1 subject^1.4 title_stemmed^2.0 title^1.5 + + + ord(weight)^0.5 recip(rord(iind),1,1000,1000)^0.3 + + + 3<-1 5<-2 6<90% + + 100 + + + + *:* + 0.01 + + text^0.5 features_t^1.0 subject^1.4 title_stemmed^2.0 + + + text^0.2 features_t^1.1 subject^1.4 title_stemmed^2.0 title^1.5 + + + ord(weight)^0.5 recip(rord(iind),1,1000,1000)^0.3 + + + 3<-1 5<-2 6<90% + + 100 + + + + 1000 + 1.4142135 + 12 + foo + + + sqrt 2 + log 10 + + + + + + + + 4 + true + text,name,subject,title,whitetok + + + + + + + 4 + true + text,name,subject,title,whitetok + + + + + + false + + + + + string + elevate.xml + + + + + explicit + + + elevate + + + + + lowerfilt + + + default + lowerfilt + spellchecker1 + true + + + + jarowinkler + lowerfilt + + org.apache.lucene.search.spell.JaroWinklerDistance + spellchecker2 + + + + solr.FileBasedSpellChecker + external + spellings.txt + UTF-8 + spellchecker3 + + + + + + + + + false + + false + + 1 + + + spellcheck + + + + + + + + 100 + + + + + + 70 + + + + + + + ]]> + ]]> + + + + + + + + + + max-age=30, public + + + + + solr + solrconfig.xml scheam.xml admin-extra.html + + + + prefix-${solr.test.sys.prop2}-suffix + + + + + +