SOLR-7741: Add missing fields to SolrIndexerConfig.toMap

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1689041 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ramkumar Aiyengar 2015-07-03 16:00:56 +00:00
parent f6ff2431bd
commit 07f8c4ec5b
3 changed files with 68 additions and 7 deletions

View File

@ -195,6 +195,9 @@ Bug Fixes
* SOLR-7673: Race condition in shard splitting can cause operation to hang indefinitely
or sub-shards to never become active. (shalin)
* SOLR-7741: Add missing fields to SolrIndexerConfig.toMap
(Mike Drob, Christine Poerschke via Ramkumar Aiyengar)
Optimizations
----------------------

View File

@ -169,15 +169,18 @@ public class SolrIndexConfig implements MapSerializable {
}
@Override
public Map<String, Object> toMap() {
Map<String, Object> m = ZkNodeProps.makeMap("maxBufferedDocs", maxBufferedDocs,
Map<String, Object> m = ZkNodeProps.makeMap("useCompoundFile", effectiveUseCompoundFileSetting,
"maxBufferedDocs", maxBufferedDocs,
"maxMergeDocs", maxMergeDocs,
"maxIndexingThreads", maxIndexingThreads,
"mergeFactor", mergeFactor,
"ramBufferSizeMB", ramBufferSizeMB,
"writeLockTimeout", writeLockTimeout,
"lockType", lockType);
"lockType", lockType,
"infoStreamEnabled", infoStream != InfoStream.NO_OUTPUT);
if(mergeSchedulerInfo != null) m.put("mergeScheduler",mergeSchedulerInfo.toMap());
if(mergePolicyInfo != null) m.put("mergeScheduler",mergePolicyInfo.toMap());
if(mergePolicyInfo != null) m.put("mergePolicy",mergePolicyInfo.toMap());
if(mergedSegmentWarmerInfo != null) m.put("mergedSegmentWarmer",mergedSegmentWarmerInfo.toMap());
return m;
}

View File

@ -19,6 +19,8 @@ package org.apache.solr.update;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.lucene.index.ConcurrentMergeScheduler;
@ -45,6 +47,10 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
}
private final String instanceDir = new File("solr", "collection1").getPath();
private final String solrConfigFileNameWarmer = "solrconfig-warmer.xml";
private final String solrConfigFileNameTieredMergePolicy = "solrconfig-tieredmergepolicy.xml";
@Test
public void testFailingSolrIndexConfigCreation() {
@ -62,8 +68,7 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {
@Test
public void testTieredMPSolrIndexConfigCreation() throws Exception {
SolrConfig solrConfig = new SolrConfig("solr" + File.separator
+ "collection1", "solrconfig-tieredmergepolicy.xml", null);
SolrConfig solrConfig = new SolrConfig(instanceDir, solrConfigFileNameTieredMergePolicy, null);
SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null,
null);
assertNotNull(solrIndexConfig);
@ -87,8 +92,7 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {
}
public void testMergedSegmentWarmerIndexConfigCreation() throws Exception {
SolrConfig solrConfig = new SolrConfig("solr" + File.separator
+ "collection1", "solrconfig-warmer.xml", null);
SolrConfig solrConfig = new SolrConfig(instanceDir, solrConfigFileNameWarmer, null);
SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);
assertNotNull(solrIndexConfig);
assertNotNull(solrIndexConfig.mergedSegmentWarmerInfo);
@ -100,4 +104,55 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {
assertEquals(SimpleMergedSegmentWarmer.class, iwc.getMergedSegmentWarmer().getClass());
}
public void testToMap() throws Exception {
final String solrConfigFileName = (random().nextBoolean() ? solrConfigFileNameWarmer : solrConfigFileNameTieredMergePolicy);
SolrConfig solrConfig = new SolrConfig(instanceDir, solrConfigFileName, null);
SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);
assertNotNull(solrIndexConfig);
assertNotNull(solrIndexConfig.mergePolicyInfo);
if (solrConfigFileName.equals(solrConfigFileNameWarmer)) {
assertNotNull(solrIndexConfig.mergedSegmentWarmerInfo);
} else {
assertNull(solrIndexConfig.mergedSegmentWarmerInfo);
}
assertNotNull(solrIndexConfig.mergeSchedulerInfo);
Map<String, Object> m = solrIndexConfig.toMap();
int mSizeExpected = 0;
++mSizeExpected; assertTrue(m.get("useCompoundFile") instanceof Boolean);
++mSizeExpected; assertTrue(m.get("maxBufferedDocs") instanceof Integer);
++mSizeExpected; assertTrue(m.get("maxMergeDocs") instanceof Integer);
++mSizeExpected; assertTrue(m.get("maxIndexingThreads") instanceof Integer);
++mSizeExpected; assertTrue(m.get("mergeFactor") instanceof Integer);
++mSizeExpected; assertTrue(m.get("ramBufferSizeMB") instanceof Double);
++mSizeExpected; assertTrue(m.get("writeLockTimeout") instanceof Integer);
++mSizeExpected; assertTrue(m.get("lockType") instanceof String);
{
final String lockType = (String)m.get("lockType");
assertTrue(SolrIndexConfig.LOCK_TYPE_SIMPLE.equals(lockType) ||
SolrIndexConfig.LOCK_TYPE_NATIVE.equals(lockType) ||
SolrIndexConfig.LOCK_TYPE_SINGLE.equals(lockType) ||
SolrIndexConfig.LOCK_TYPE_NONE.equals(lockType));
}
++mSizeExpected; assertTrue(m.get("infoStreamEnabled") instanceof Boolean);
{
assertFalse(Boolean.valueOf(m.get("infoStreamEnabled").toString()).booleanValue());
}
++mSizeExpected; assertTrue(m.get("mergeScheduler") instanceof Map);
++mSizeExpected; assertTrue(m.get("mergePolicy") instanceof Map);
if (solrConfigFileName.equals(solrConfigFileNameWarmer)) {
++mSizeExpected; assertTrue(m.get("mergedSegmentWarmer") instanceof Map);
} else {
assertNull(m.get("mergedSegmentWarmer"));
}
assertEquals(mSizeExpected, m.size());
}
}