You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ho...@apache.org on 2008/12/16 21:45:18 UTC
svn commit: r727139 -
/lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexWriter.java
Author: hossman
Date: Tue Dec 16 12:45:17 2008
New Revision: 727139
URL: http://svn.apache.org/viewvc?rev=727139&view=rev
Log:
SOLR-923: some SolrIndexWriter.getDirectory cleanup
Modified:
lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexWriter.java
Modified: lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexWriter.java?rev=727139&r1=727138&r2=727139&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexWriter.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/update/SolrIndexWriter.java Tue Dec 16 12:45:17 2008
@@ -20,7 +20,9 @@
import org.apache.lucene.index.*;
import org.apache.lucene.store.*;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.DirectoryFactory;
+import org.apache.solr.core.StandardDirectoryFactory;
import org.apache.solr.schema.IndexSchema;
import org.slf4j.Logger;
@@ -107,37 +109,18 @@
return d;
}
+ /** @deprecated remove when getDirectory(String,SolrIndexConfig) is gone */
+ private static DirectoryFactory LEGACY_DIR_FACTORY
+ = new StandardDirectoryFactory();
+ static {
+ LEGACY_DIR_FACTORY.init(new NamedList());
+ }
+
/**
- * @deprecated use getDirectory(DirectoryFactory directoryFactory, SolrIndexConfig config)
+ * @deprecated use getDirectory(String path, DirectoryFactory directoryFactory, SolrIndexConfig config)
*/
public static Directory getDirectory(String path, SolrIndexConfig config) throws IOException {
- Directory d = FSDirectory.getDirectory(path);
-
- String rawLockType = (null == config) ? null : config.lockType;
- if (null == rawLockType) {
- // we default to "simple" for backwards compatibility
- log.warn("No lockType configured for " + path + " assuming 'simple'");
- rawLockType = "simple";
- }
- final String lockType = rawLockType.toLowerCase().trim();
-
- if ("simple".equals(lockType)) {
- // multiple SimpleFSLockFactory instances should be OK
- d.setLockFactory(new SimpleFSLockFactory(path));
- } else if ("native".equals(lockType)) {
- d.setLockFactory(new NativeFSLockFactory(path));
- } else if ("single".equals(lockType)) {
- if (!(d.getLockFactory() instanceof SingleInstanceLockFactory))
- d.setLockFactory(new SingleInstanceLockFactory());
- } else if ("none".equals(lockType)) {
- // Recipe for disaster
- log.error("CONFIGURATION WARNING: locks are disabled on " + path);
- d.setLockFactory(new NoLockFactory());
- } else {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "Unrecognized lockType: " + rawLockType);
- }
- return d;
+ return getDirectory(path, LEGACY_DIR_FACTORY, config);
}
/**