SOLR-6125: Allow SolrIndexWriter to close without waiting for merges

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1603600 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alan Woodward 2014-06-18 19:33:51 +00:00
parent 1195909d13
commit ac9f70adc8
3 changed files with 12 additions and 2 deletions

View File

@ -150,6 +150,9 @@ New Features
* SOLR-6150: Add new AnalyticsQuery to support pluggable analytics
(Joel Bernstein)
* SOLR-6125: Allow SolrIndexWriter to close without waiting for merges
(Christine Poerschke via Alan Woodward)
Bug Fixes
----------------------

View File

@ -315,6 +315,7 @@ public class SolrConfig extends Config {
return new UpdateHandlerInfo(get("updateHandler/@class",null),
getInt("updateHandler/autoCommit/maxDocs",-1),
getInt("updateHandler/autoCommit/maxTime",-1),
getBool("updateHandler/indexWriter/closeWaitsForMerges",true),
getBool("updateHandler/autoCommit/openSearcher",true),
getInt("updateHandler/commitIntervalLowerBound",-1),
getInt("updateHandler/autoSoftCommit/maxDocs",-1),
@ -497,6 +498,7 @@ public class SolrConfig extends Config {
public final String className;
public final int autoCommmitMaxDocs,autoCommmitMaxTime,commitIntervalLowerBound,
autoSoftCommmitMaxDocs,autoSoftCommmitMaxTime;
public final boolean indexWriterCloseWaitsForMerges;
public final boolean openSearcher; // is opening a new searcher part of hard autocommit?
public final boolean commitWithinSoftCommit;
@ -505,11 +507,12 @@ public class SolrConfig extends Config {
* @param autoCommmitMaxTime set -1 as default
* @param commitIntervalLowerBound set -1 as default
*/
public UpdateHandlerInfo(String className, int autoCommmitMaxDocs, int autoCommmitMaxTime, boolean openSearcher, int commitIntervalLowerBound,
public UpdateHandlerInfo(String className, int autoCommmitMaxDocs, int autoCommmitMaxTime, boolean indexWriterCloseWaitsForMerges, boolean openSearcher, int commitIntervalLowerBound,
int autoSoftCommmitMaxDocs, int autoSoftCommmitMaxTime, boolean commitWithinSoftCommit) {
this.className = className;
this.autoCommmitMaxDocs = autoCommmitMaxDocs;
this.autoCommmitMaxTime = autoCommmitMaxTime;
this.indexWriterCloseWaitsForMerges = indexWriterCloseWaitsForMerges;
this.openSearcher = openSearcher;
this.commitIntervalLowerBound = commitIntervalLowerBound;

View File

@ -94,6 +94,8 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
protected boolean commitWithinSoftCommit;
protected boolean indexWriterCloseWaitsForMerges;
public DirectUpdateHandler2(SolrCore core) {
super(core);
@ -110,6 +112,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
softCommitTracker = new CommitTracker("Soft", core, softCommitDocsUpperBound, softCommitTimeUpperBound, true, true);
commitWithinSoftCommit = updateHandlerInfo.commitWithinSoftCommit;
indexWriterCloseWaitsForMerges = updateHandlerInfo.indexWriterCloseWaitsForMerges;
}
@ -129,6 +132,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
softCommitTracker = new CommitTracker("Soft", core, softCommitDocsUpperBound, softCommitTimeUpperBound, updateHandlerInfo.openSearcher, true);
commitWithinSoftCommit = updateHandlerInfo.commitWithinSoftCommit;
indexWriterCloseWaitsForMerges = updateHandlerInfo.indexWriterCloseWaitsForMerges;
UpdateLog existingLog = updateHandler.getUpdateLog();
if (this.ulog != null && this.ulog == existingLog) {
@ -788,7 +792,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
if (writer != null) {
try {
writer.waitForMerges();
if (indexWriterCloseWaitsForMerges) writer.waitForMerges();
} finally {
writer.close();
}