Skip to content

Apache Lucene open-source search software

SOLR-2670: add NIOFSDirectoryFactory

Yonik Seeley2ff9fa27e7c2
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index eab05b7b15c..dca1dd264a3 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -320,6 +320,8 @@ New Features
* SOLR-2584: add UniqFieldsUpdateProcessor that removes duplicate values in the
specified fields. (Elmer Garduno, koji)
+* SOLR-2670: Added NIOFSDirectoryFactory (yonik)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/core/NIOFSDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/NIOFSDirectoryFactory.java
new file mode 100644
index 00000000000..ce585e78497
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/core/NIOFSDirectoryFactory.java
@@ -0,0 +1,36 @@
+package org.apache.solr.core;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.NIOFSDirectory;
+
+import java.io.File;
+import java.io.IOException;
+
+
+/**
+ * Factory to instantiate {@link org.apache.lucene.store.NIOFSDirectory}
+ *
+ **/
+public class NIOFSDirectoryFactory extends DirectoryFactory {
+
+ @Override
+ public Directory open(String path) throws IOException {
+ return new NIOFSDirectory(new File(path));
+ }
+}
diff --git a/solr/example/solr/conf/solrconfig.xml b/solr/example/solr/conf/solrconfig.xml
index 3a607508948..4c617702c40 100755
--- a/solr/example/solr/conf/solrconfig.xml
+++ b/solr/example/solr/conf/solrconfig.xml
@@ -87,7 +87,12 @@
<!-- The DirectoryFactory to use for indexes.
solr.StandardDirectoryFactory, the default, is filesystem
- based. solr.RAMDirectoryFactory is memory based, not
+ based and tries to pick the best implementation for the current
+ JVM and platform. One can force a particular implementation
+ via solr.MMapDirectoryFactory, solr.NIOFSDirectoryFactory, or
+ solr.SimpleFSDirectoryFactory.
+
+ solr.RAMDirectoryFactory is memory based, not
persistent, and doesn't work with replication.
-->
<directoryFactory name="DirectoryFactory"