LUCENE-6097: make abort/waitForMerges private

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1643891 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-12-08 19:18:48 +00:00
parent d2ff57a8b7
commit 0c28951031
8 changed files with 19 additions and 74 deletions

View File

@ -295,6 +295,10 @@ API Changes
won't be trappy if codec tries to use them during docvalues updates.
(Robert Muir)
* LUCENE-6097: Remove dangerous / overly expert
IndexWriter.abortMerges and waitForMerges methods. (Robert Muir,
Mike McCandless)
Bug Fixes
* LUCENE-5650: Enforce read-only access to any path outside the temporary

View File

@ -46,9 +46,11 @@ public class CloseIndexTask extends PerfTask {
infoStream.close();
}
if (doWait == false) {
iw.abortMerges();
iw.commit();
iw.rollback();
} else {
iw.close();
}
iw.close();
getRunData().setIndexWriter(null);
}
return 1;

View File

@ -1,40 +0,0 @@
package org.apache.lucene.benchmark.byTask.tasks;
/*
* 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.HashMap;
import java.util.Map;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexReader;
/**
* Waits for merges to finish.
*/
public class WaitForMergesTask extends PerfTask {
public WaitForMergesTask(PerfRunData runData) {
super(runData);
}
@Override
public int doLogic() throws Exception {
getRunData().getIndexWriter().waitForMerges();
return 1;
}
}

View File

@ -532,7 +532,6 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
"{ [ AddDoc]: 4} : * ",
"ResetInputs ",
"{ [ AddDoc]: 4} : * ",
"WaitForMerges",
"CloseIndex",
};
@ -568,7 +567,6 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
" ResetSystemErase",
" CreateIndex",
" { \"AddDocs\" AddDoc > : * ",
" WaitForMerges",
" CloseIndex",
"} : 2",
};

View File

@ -1624,11 +1624,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
* newly created segments will not be merged unless you
* call forceMerge again.</p>
*
* <p><b>NOTE</b>: if you call {@link #abortMerges}, which
* aborts all running merges, then any thread still
* running this method might hit a {@link
* MergePolicy.MergeAbortedException}.
*
* @param maxNumSegments maximum number of segments left
* in the index after merging finishes
*
@ -1741,12 +1736,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
* specify whether the call should block until the
* operation completes. This is only meaningful with a
* {@link MergeScheduler} that is able to run merges in
* background threads.
*
* <p><b>NOTE</b>: if you call {@link #abortMerges}, which
* aborts all running merges, then any thread still
* running this method might hit a {@link
* MergePolicy.MergeAbortedException}. */
* background threads. */
public void forceMergeDeletes(boolean doWait)
throws IOException {
ensureOpen();
@ -2154,7 +2144,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
/** Aborts running merges. Be careful when using this
* method: when you abort a long-running merge, you lose
* a lot of work that must later be redone. */
public synchronized void abortMerges() {
private synchronized void abortMerges() {
stopMerges = true;
// Abort all pending & running merges:
@ -2202,7 +2192,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
* <p>It is guaranteed that any merges started prior to calling this method
* will have completed once this method completes.</p>
*/
public void waitForMerges() throws IOException {
void waitForMerges() throws IOException {
// Give merge scheduler last chance to run, in case
// any pending merges are waiting. We can't hold IW's lock
@ -2495,11 +2485,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
* {@code maxMergeAtOnce} parameter, you should pass that many readers in one
* call.
*
* <p>
* <b>NOTE</b>: if you call {@link #abortMerges}, which
* aborts all running merges, then any thread still running this method might
* hit a {@link MergePolicy.MergeAbortedException}.
*
* @throws CorruptIndexException
* if the index is corrupt
* @throws IOException

View File

@ -715,10 +715,10 @@ public class TestAddIndexes extends LuceneTestCase {
void close(boolean doWait) throws Throwable {
didClose = true;
if (doWait == false) {
writer2.abortMerges();
writer2.rollback();
} else {
writer2.close();
}
//writer2.close();
writer2.rollback();
}
void closeDir() throws Throwable {

View File

@ -435,16 +435,16 @@ public class TestIndexWriterReader extends LuceneTestCase {
void close(boolean doWait) throws Throwable {
didClose = true;
if (doWait) {
mainWriter.waitForMerges();
mainWriter.close();
} else {
mainWriter.abortMerges();
mainWriter.rollback();
}
mainWriter.close();
}
void closeDir() throws Throwable {
for (int i = 0; i < numDirs; i++)
for (int i = 0; i < numDirs; i++) {
readers[i].close();
}
addDir.close();
}

View File

@ -793,11 +793,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
}
if (writer != null) {
try {
if (indexWriterCloseWaitsForMerges) writer.waitForMerges();
} finally {
writer.close();
}
writer.close();
}
} finally {