Disable commitWithin when running Reindex

Disable the 'commitWithin' from within Reindex by overriding
the configuration with '-1'. Treat negative values as the
original behavior, auto-flushing but not auto-committing, which
is the least safe but the most efficient for reindexing the
entire site. 

Change-Id: Ifdba797bee871d2a3d8928810a6304bacb850c8c
This commit is contained in:
Bruce Zu
2014-03-21 10:03:05 +08:00
committed by David Pursehouse
parent 3daa739e13
commit af058e6dd3
5 changed files with 64 additions and 48 deletions

View File

@@ -137,7 +137,7 @@ public class LuceneChangeIndex implements ChangeIndex {
static class GerritIndexWriterConfig {
private final IndexWriterConfig luceneConfig;
private final long commitWithinMs;
private long commitWithinMs;
private GerritIndexWriterConfig(Version version, Config cfg, String name) {
luceneConfig = new IndexWriterConfig(version,
@@ -150,9 +150,13 @@ public class LuceneChangeIndex implements ChangeIndex {
luceneConfig.setMaxBufferedDocs(cfg.getInt(
"index", name, "maxBufferedDocs",
IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS));
commitWithinMs = ConfigUtil.getTimeUnit(
cfg, "index", name, "commitWithin",
MILLISECONDS.convert(5, MINUTES), MILLISECONDS);
try {
commitWithinMs =
ConfigUtil.getTimeUnit(cfg, "index", name, "commitWithin",
MILLISECONDS.convert(5, MINUTES), MILLISECONDS);
} catch (IllegalArgumentException e) {
commitWithinMs = cfg.getLong("index", name, "commitWithin", 0);
}
}
IndexWriterConfig getLuceneConfig() {