mirror of
https://github.com/apache/lucene.git
synced 2025-02-22 18:27:21 +00:00
SOLR-8505: core/DirectoryFactory.LOCK_TYPE_HDFS - add & use it instead of String literals
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1723751 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fe4d702f83
commit
2580956b8b
@ -454,6 +454,9 @@ Other Changes
|
||||
* SOLR-8504: (IndexSchema|SolrIndexConfig)Test: private static finals for
|
||||
solrconfig.xml and schema.xml String literals. (Christine Poerschke)
|
||||
|
||||
* SOLR-8505: core/DirectoryFactory.LOCK_TYPE_HDFS - add & use it instead of String literals
|
||||
(Christine Poerschke)
|
||||
|
||||
================== 5.4.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
|
||||
|
@ -43,6 +43,7 @@ import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.core.CoreDescriptor;
|
||||
import org.apache.solr.core.DirectoryFactory;
|
||||
import org.apache.solr.core.HdfsDirectoryFactory;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
@ -151,7 +152,7 @@ class SolrRecordWriter<K, V> extends RecordWriter<K, V> {
|
||||
|
||||
// TODO: This is fragile and should be well documented
|
||||
System.setProperty("solr.directoryFactory", HdfsDirectoryFactory.class.getName());
|
||||
System.setProperty("solr.lock.type", "hdfs");
|
||||
System.setProperty("solr.lock.type", DirectoryFactory.LOCK_TYPE_HDFS);
|
||||
System.setProperty("solr.hdfs.nrtcachingdirectory", "false");
|
||||
System.setProperty("solr.hdfs.blockcache.enabled", "false");
|
||||
System.setProperty("solr.autoCommit.maxTime", "600000");
|
||||
|
@ -60,6 +60,7 @@ public abstract class DirectoryFactory implements NamedListInitializedPlugin,
|
||||
public final static String LOCK_TYPE_NATIVE = "native";
|
||||
public final static String LOCK_TYPE_SINGLE = "single";
|
||||
public final static String LOCK_TYPE_NONE = "none";
|
||||
public final static String LOCK_TYPE_HDFS = "hdfs";
|
||||
|
||||
/**
|
||||
* Indicates a Directory will no longer be used, and when its ref count
|
||||
|
@ -155,12 +155,12 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol
|
||||
@Override
|
||||
protected LockFactory createLockFactory(String rawLockType) throws IOException {
|
||||
if (null == rawLockType) {
|
||||
LOG.warn("No lockType configured, assuming 'hdfs'.");
|
||||
rawLockType = "hdfs";
|
||||
rawLockType = DirectoryFactory.LOCK_TYPE_HDFS;
|
||||
LOG.warn("No lockType configured, assuming '"+rawLockType+"'.");
|
||||
}
|
||||
final String lockType = rawLockType.toLowerCase(Locale.ROOT).trim();
|
||||
switch (lockType) {
|
||||
case "hdfs":
|
||||
case DirectoryFactory.LOCK_TYPE_HDFS:
|
||||
return HdfsLockFactory.INSTANCE;
|
||||
case DirectoryFactory.LOCK_TYPE_SINGLE:
|
||||
return new SingleInstanceLockFactory();
|
||||
|
@ -21,6 +21,7 @@ import org.apache.hadoop.hdfs.server.namenode.ha.HATestUtil;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.util.IOUtils;
|
||||
import org.apache.solr.core.DirectoryFactory;
|
||||
import org.apache.solr.util.HdfsUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -87,7 +88,7 @@ public class HdfsTestUtil {
|
||||
|
||||
System.setProperty("test.build.data", dir + File.separator + "hdfs" + File.separator + "build");
|
||||
System.setProperty("test.cache.data", dir + File.separator + "hdfs" + File.separator + "cache");
|
||||
System.setProperty("solr.lock.type", "hdfs");
|
||||
System.setProperty("solr.lock.type", DirectoryFactory.LOCK_TYPE_HDFS);
|
||||
|
||||
|
||||
System.setProperty("solr.hdfs.blockcache.global", Boolean.toString(LuceneTestCase.random().nextBoolean()));
|
||||
|
@ -26,6 +26,7 @@ public class DirectoryFactoryTest extends LuceneTestCase {
|
||||
assertEquals("native", DirectoryFactory.LOCK_TYPE_NATIVE);
|
||||
assertEquals("single", DirectoryFactory.LOCK_TYPE_SINGLE);
|
||||
assertEquals("none", DirectoryFactory.LOCK_TYPE_NONE);
|
||||
assertEquals("hdfs", DirectoryFactory.LOCK_TYPE_HDFS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -137,7 +137,8 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {
|
||||
assertTrue(DirectoryFactory.LOCK_TYPE_SIMPLE.equals(lockType) ||
|
||||
DirectoryFactory.LOCK_TYPE_NATIVE.equals(lockType) ||
|
||||
DirectoryFactory.LOCK_TYPE_SINGLE.equals(lockType) ||
|
||||
DirectoryFactory.LOCK_TYPE_NONE.equals(lockType));
|
||||
DirectoryFactory.LOCK_TYPE_NONE.equals(lockType) ||
|
||||
DirectoryFactory.LOCK_TYPE_HDFS.equals(lockType));
|
||||
}
|
||||
|
||||
++mSizeExpected; assertTrue(m.get("infoStreamEnabled") instanceof Boolean);
|
||||
|
Loading…
x
Reference in New Issue
Block a user