You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/01/13 09:54:15 UTC
svn commit: r1651305 - in /lucene/dev/branches/branch_5x/lucene/core/src:
java/org/apache/lucene/index/MergeRateLimiter.java
test/org/apache/lucene/index/TestMergeRateLimiter.java
Author: mikemccand
Date: Tue Jan 13 08:54:14 2015
New Revision: 1651305
URL: http://svn.apache.org/r1651305
Log:
LUCENE-6119: make sure minPauseCheckBytes is set on init of MergeRateLimiter
Added:
lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestMergeRateLimiter.java (with props)
Modified:
lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/MergeRateLimiter.java
Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/MergeRateLimiter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/MergeRateLimiter.java?rev=1651305&r1=1651304&r2=1651305&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/MergeRateLimiter.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/MergeRateLimiter.java Tue Jan 13 08:54:14 2015
@@ -36,8 +36,7 @@ public class MergeRateLimiter extends Ra
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 Ra
/** 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
Added: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestMergeRateLimiter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestMergeRateLimiter.java?rev=1651305&view=auto
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestMergeRateLimiter.java (added)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestMergeRateLimiter.java Tue Jan 13 08:54:14 2015
@@ -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();
+ }
+}