Replace Reindex --dry-run with --output

The line of what was a "dry run" was a bit arbitrary, doing all the
Gerrit processing (including potential side effects like writing to
persistent caches) but not all the index-specific processing, which
could still be useful for evaluation or debugging purposes. Instead,
provide an output base so administrators can test the indexing
behavior without operating on production index data.

For Lucene, this flag is interpreted as a path to the index
directory; for Solr, it is a prefix added to the collection names.

Change-Id: Ic4808d1e3467a780a818ac7d1c89de13610da630
This commit is contained in:
Dave Borowitz
2013-06-28 12:40:59 -06:00
parent 1d2a998298
commit 97a01dbb05
5 changed files with 26 additions and 37 deletions

View File

@@ -98,8 +98,8 @@ public class Reindex extends SiteProgram {
@Option(name = "--threads", usage = "Number of threads to use for indexing")
private int threads = Runtime.getRuntime().availableProcessors();
@Option(name = "--dry-run", usage = "Dry run: don't write anything to index")
private boolean dryRun;
@Option(name = "--output", usage = "Prefix for output; path for local disk index, or prefix for remote index")
private String outputBase;
@Option(name = "--verbose", usage = "Output debug information for each change")
private boolean verbose;
@@ -142,10 +142,10 @@ public class Reindex extends SiteProgram {
AbstractModule changeIndexModule;
switch (IndexModule.getIndexType(dbInjector)) {
case LUCENE:
changeIndexModule = new LuceneIndexModule(false, threads, dryRun);
changeIndexModule = new LuceneIndexModule(false, threads, outputBase);
break;
case SOLR:
changeIndexModule = new SolrIndexModule(false, threads);
changeIndexModule = new SolrIndexModule(false, threads, outputBase);
break;
default:
changeIndexModule = new NoIndexModule();
@@ -208,9 +208,6 @@ public class Reindex extends SiteProgram {
}
private void deleteAll() throws IOException {
if (dryRun) {
return;
}
ChangeIndex index = sysInjector.getInstance(ChangeIndex.class);
index.deleteAll();
}
@@ -470,9 +467,6 @@ public class Reindex extends SiteProgram {
private void writeVersion() throws IOException,
ConfigInvalidException {
if (dryRun) {
return;
}
ChangeIndex index = sysInjector.getInstance(ChangeIndex.class);
index.finishIndex();
}