mirror of https://github.com/apache/lucene.git
LUCENE-6119: make sure minPauseCheckBytes is set on init of MergeRateLimiter
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1651307 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a4e089e662
commit
d492a3b1b4
|
@ -36,8 +36,7 @@ public class MergeRateLimiter extends RateLimiter {
|
|||
private final static int MIN_PAUSE_CHECK_MSEC = 25;
|
||||
volatile long totalBytesWritten;
|
||||
|
||||
// By default no IO limit:
|
||||
double mbPerSec = Double.POSITIVE_INFINITY;
|
||||
double mbPerSec;
|
||||
private long lastNS;
|
||||
private long minPauseCheckBytes;
|
||||
private boolean abort;
|
||||
|
@ -51,6 +50,9 @@ public class MergeRateLimiter extends RateLimiter {
|
|||
/** Sole constructor. */
|
||||
public MergeRateLimiter(MergePolicy.OneMerge merge) {
|
||||
this.merge = merge;
|
||||
|
||||
// Initially no IO limit; use setter here so minPauseCheckBytes is set:
|
||||
setMBPerSec(Double.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.apache.lucene.index;
|
||||
|
||||
/*
|
||||
* 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 java.util.Collections;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
||||
public class TestMergeRateLimiter extends LuceneTestCase {
|
||||
public void testInitDefaults() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
|
||||
w.addDocument(new Document());
|
||||
w.close();
|
||||
MergePolicy.OneMerge merge = new MergePolicy.OneMerge(SegmentInfos.readLatestCommit(dir).asList());
|
||||
MergeRateLimiter rateLimiter = new MergeRateLimiter(merge);
|
||||
assertEquals(Double.POSITIVE_INFINITY, rateLimiter.getMBPerSec(), 0.0);
|
||||
assertTrue(rateLimiter.getMinPauseCheckBytes() > 0);
|
||||
dir.close();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue