From 4eead83a83235b235145f07f0a625055b860ad65 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Fri, 20 Apr 2018 11:34:04 +0200 Subject: [PATCH] SOLR-11200: A new CMS config option 'ioThrottle' to manually enable/disable ConcurrentMergeSchedule.doAutoIOThrottle. (Amrit Sarkar, Nawab Zada Asad iqbal) --- solr/CHANGES.txt | 3 ++ .../apache/solr/update/SolrIndexConfig.java | 4 ++ .../solrconfig-concurrentmergescheduler.xml | 37 +++++++++++++++++++ .../solr/update/SolrIndexConfigTest.java | 24 ++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 solr/core/src/test-files/solr/collection1/conf/solrconfig-concurrentmergescheduler.xml diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index be3f7042303..516a0d794ec 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -69,6 +69,9 @@ Upgrade Notes New Features ---------------------- +* SOLR-11200: A new CMS config option 'ioThrottle' to manually enable/disable + ConcurrentMergeSchedule.doAutoIOThrottle. (Amrit Sarkar, Nawab Zada Asad iqbal via Dawid Weiss) + * SOLR-11670: Implement a periodic house-keeping task. This uses a scheduled autoscaling trigger and currently performs cleanup of old inactive shards. (ab, shalin) 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 c663783e83c..48b241751b8 100644 --- a/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java +++ b/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java @@ -299,6 +299,10 @@ public class SolrIndexConfig implements MapSerializable { maxThreadCount = ((ConcurrentMergeScheduler) scheduler).getMaxThreadCount(); } ((ConcurrentMergeScheduler)scheduler).setMaxMergesAndThreads(maxMergeCount, maxThreadCount); + Boolean ioThrottle = (Boolean) args.remove("ioThrottle"); + if (ioThrottle != null && !ioThrottle) { //by-default 'enabled' + ((ConcurrentMergeScheduler) scheduler).disableAutoIOThrottle(); + } SolrPluginUtils.invokeSetters(scheduler, args); } else { SolrPluginUtils.invokeSetters(scheduler, mergeSchedulerInfo.initArgs); diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-concurrentmergescheduler.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-concurrentmergescheduler.xml new file mode 100644 index 00000000000..140c4cfeedc --- /dev/null +++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-concurrentmergescheduler.xml @@ -0,0 +1,37 @@ + + + + + + ${tests.luceneMatchVersion:LATEST} + + + + + ${useCompoundFile:false} + + + 987 + 42 + false + + + + + + diff --git a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java index ec5719ca3df..d5ebf051d9f 100644 --- a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java +++ b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java @@ -48,6 +48,7 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 { private static final String solrConfigFileName = "solrconfig.xml"; private static final String solrConfigFileNameWarmerRandomMergePolicyFactory = "solrconfig-warmer-randommergepolicyfactory.xml"; private static final String solrConfigFileNameTieredMergePolicyFactory = "solrconfig-tieredmergepolicyfactory.xml"; + private static final String solrConfigFileNameConnMSPolicyFactory = "solrconfig-concurrentmergescheduler.xml"; private static final String solrConfigFileNameSortingMergePolicyFactory = "solrconfig-sortingmergepolicyfactory.xml"; private static final String schemaFileName = "schema.xml"; @@ -93,6 +94,29 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 { ConcurrentMergeScheduler ms = (ConcurrentMergeScheduler) iwc.getMergeScheduler(); assertEquals("ms.maxMergeCount", 987, ms.getMaxMergeCount()); assertEquals("ms.maxThreadCount", 42, ms.getMaxThreadCount()); + assertEquals("ms.isAutoIOThrottle", true, ms.getAutoIOThrottle()); + + } + + @Test + public void testConcurrentMergeSchedularSolrIndexConfigCreation() throws Exception { + String solrConfigFileName = solrConfigFileNameConnMSPolicyFactory; + SolrConfig solrConfig = new SolrConfig(instanceDir, solrConfigFileName, null); + SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null); + IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema(schemaFileName, solrConfig); + + h.getCore().setLatestSchema(indexSchema); + IndexWriterConfig iwc = solrIndexConfig.toIndexWriterConfig(h.getCore()); + + assertNotNull("null mp", iwc.getMergePolicy()); + assertTrue("mp is not TieredMergePolicy", iwc.getMergePolicy() instanceof TieredMergePolicy); + + assertNotNull("null ms", iwc.getMergeScheduler()); + assertTrue("ms is not CMS", iwc.getMergeScheduler() instanceof ConcurrentMergeScheduler); + ConcurrentMergeScheduler ms = (ConcurrentMergeScheduler) iwc.getMergeScheduler(); + assertEquals("ms.maxMergeCount", 987, ms.getMaxMergeCount()); + assertEquals("ms.maxThreadCount", 42, ms.getMaxThreadCount()); + assertEquals("ms.isAutoIOThrottle", false, ms.getAutoIOThrottle()); }