Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-3929: support configuring IndexWriter max thread count in solrconfig

Mark Robert Miller1cadf9c5bb28
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e964d57bde6..cb4852e907f 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -42,6 +42,10 @@ New Features
values of a multiValued field in their original order when highlighting.
(Joel Bernstein via yonik)
+* SOLR-3929
+support configuring IndexWriter max thread count in solrconfig
+
+ (phunt via Mark Miller)
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java b/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
index a5693c1e4d2..6035304f948 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
@@ -44,6 +44,7 @@ public class SolrIndexConfig {
public final boolean useCompoundFile;
public final int maxBufferedDocs;
public final int maxMergeDocs;
+ public final int maxIndexingThreads;
public final int mergeFactor;
public final double ramBufferSizeMB;
@@ -71,6 +72,7 @@ public class SolrIndexConfig {
useCompoundFile = false;
maxBufferedDocs = -1;
maxMergeDocs = -1;
+ maxIndexingThreads = IndexWriterConfig.DEFAULT_MAX_THREAD_STATES;
mergeFactor = -1;
ramBufferSizeMB = 32;
writeLockTimeout = -1;
@@ -116,6 +118,7 @@ public class SolrIndexConfig {
useCompoundFile=solrConfig.getBool(prefix+"/useCompoundFile", def.useCompoundFile);
maxBufferedDocs=solrConfig.getInt(prefix+"/maxBufferedDocs",def.maxBufferedDocs);
maxMergeDocs=solrConfig.getInt(prefix+"/maxMergeDocs",def.maxMergeDocs);
+ maxIndexingThreads=solrConfig.getInt(prefix+"/maxIndexingThreads",def.maxIndexingThreads);
mergeFactor=solrConfig.getInt(prefix+"/mergeFactor",def.mergeFactor);
ramBufferSizeMB = solrConfig.getDouble(prefix+"/ramBufferSizeMB", def.ramBufferSizeMB);
@@ -176,6 +179,10 @@ public class SolrIndexConfig {
iwc.setMergePolicy(buildMergePolicy(schema));
iwc.setMergeScheduler(buildMergeScheduler(schema));
+ if (maxIndexingThreads != -1) {
+ iwc.setMaxThreadStates(maxIndexingThreads);
+ }
+
return iwc;
}
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexconfig.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexconfig.xml
new file mode 100644
index 00000000000..74c8268c6d6
--- /dev/null
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-indexconfig.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" ?>
+
+<!--
+ 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.
+-->
+<config>
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
+
+ <indexConfig>
+ <maxIndexingThreads>123</maxIndexingThreads>
+ </indexConfig>
+</config>
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java b/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java
new file mode 100644
index 00000000000..7ccdc4d9db2
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.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.index.IndexWriterConfig;
+import org.apache.solr.SolrTestCaseJ4;
+import org.junit.BeforeClass;
+
+public class TestSolrIndexConfig extends SolrTestCaseJ4 {
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-indexconfig.xml","schema.xml");
+ }
+
+ public void testIndexConfig() throws Exception {
+ IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getSchema());
+
+ assertEquals(123, iwc.getMaxThreadStates());
+ }
+}
diff --git a/solr/example/solr/collection1/conf/solrconfig.xml b/solr/example/solr/collection1/conf/solrconfig.xml
index fd7202598c3..214dae9ba63 100755
--- a/solr/example/solr/collection1/conf/solrconfig.xml
+++ b/solr/example/solr/collection1/conf/solrconfig.xml
@@ -136,6 +136,12 @@
<!-- Maximum time to wait for a write lock (ms) for an IndexWriter. Default: 1000 -->
<!-- <writeLockTimeout>1000</writeLockTimeout> -->
+ <!-- The maximum number of simultaneous threads that may be
+ indexing documents at once in IndexWriter; if more than this
+ many threads arrive they will wait for others to finish.
+ Default in Solr/Lucene is 8. -->
+ <!-- <maxIndexingThreads>8</maxIndexingThreads> -->
+
<!-- Expert: Enabling compound file will use less files for the index,
using fewer file descriptors on the expense of performance decrease.
Default in Lucene is "true". Default in Solr is "false" (since 3.6) -->