LUCENE-6511: add CMS.getAutoIOThrottle

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1684981 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-06-11 22:02:53 +00:00
parent 414b7696eb
commit f68abe9378
4 changed files with 26 additions and 2 deletions

View File

@ -91,6 +91,9 @@ API Changes
incorrect results for Numeric fields using precisionStep
(hossman, Robert Muir)
* LUCENE-6511: Add missing ConcurrentMergeScheduler.getAutoIOThrottle
getter (Simon Willnauer, Mike McCandless)
Bug fixes
* LUCENE-6500: ParallelCompositeReader did not always call

View File

@ -214,6 +214,11 @@ public class ConcurrentMergeScheduler extends MergeScheduler {
updateMergeThreads();
}
/** Returns true if auto IO throttling is currently enabled. */
public synchronized boolean getAutoIOThrottle() {
return doAutoIOThrottle;
}
/** Returns the currently set per-merge IO writes rate limit, if {@link #enableAutoIOThrottle}
* was called, else {@code Double.POSITIVE_INFINITY}. */
public synchronized double getIORateLimitMBPerSec() {

View File

@ -635,6 +635,14 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase {
assertEquals(6, cms.getMaxMergeCount());
}
public void testAutoIOThrottleGetter() throws Exception {
ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
cms.disableAutoIOThrottle();
assertFalse(cms.getAutoIOThrottle());
cms.enableAutoIOThrottle();
assertTrue(cms.getAutoIOThrottle());
}
public void testNonSpinningDefaults() throws Exception {
ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
cms.setDefaultMaxMergesAndThreads(false);

View File

@ -915,6 +915,7 @@ public abstract class LuceneTestCase extends Assert {
cms.setMaxMergesAndThreads(maxMergeCount, maxThreadCount);
if (random().nextBoolean()) {
cms.disableAutoIOThrottle();
assertFalse(cms.getAutoIOThrottle());
}
cms.setForceMergeMBPerSec(10 + 10*random().nextDouble());
c.setMergeScheduler(cms);
@ -1180,12 +1181,19 @@ public abstract class LuceneTestCase extends Assert {
// change CMS merge parameters
MergeScheduler ms = c.getMergeScheduler();
if (ms instanceof ConcurrentMergeScheduler) {
ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler) ms;
int maxThreadCount = TestUtil.nextInt(r, 1, 4);
int maxMergeCount = TestUtil.nextInt(r, maxThreadCount, maxThreadCount + 4);
((ConcurrentMergeScheduler)ms).setMaxMergesAndThreads(maxMergeCount, maxThreadCount);
boolean enableAutoIOThrottle = random().nextBoolean();
if (enableAutoIOThrottle) {
cms.enableAutoIOThrottle();
} else {
cms.disableAutoIOThrottle();
}
cms.setMaxMergesAndThreads(maxMergeCount, maxThreadCount);
didChange = true;
}
}
if (rarely(r)) {
MergePolicy mp = c.getMergePolicy();