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:
@@ -120,7 +120,6 @@ public class LuceneChangeIndex implements ChangeIndex, LifecycleListener {
|
||||
private final Schema<ChangeData> schema;
|
||||
private final SubIndex openIndex;
|
||||
private final SubIndex closedIndex;
|
||||
private final boolean readOnly;
|
||||
|
||||
LuceneChangeIndex(@GerritServerConfig Config cfg,
|
||||
SitePaths sitePaths,
|
||||
@@ -128,15 +127,19 @@ public class LuceneChangeIndex implements ChangeIndex, LifecycleListener {
|
||||
@IndexExecutor ListeningScheduledExecutorService executor,
|
||||
FillArgs fillArgs,
|
||||
Schema<ChangeData> schema,
|
||||
boolean readOnly) throws IOException {
|
||||
String base) throws IOException {
|
||||
this.indexes = indexes;
|
||||
this.sitePaths = sitePaths;
|
||||
this.fillArgs = fillArgs;
|
||||
this.executor = executor;
|
||||
this.schema = schema;
|
||||
this.readOnly = readOnly;
|
||||
|
||||
File dir = new File(sitePaths.index_dir, "changes_" + schema.getVersion());
|
||||
File dir;
|
||||
if (base == null) {
|
||||
dir = new File(sitePaths.index_dir, "changes_" + schema.getVersion());
|
||||
} else {
|
||||
dir = new File(base);
|
||||
}
|
||||
openIndex = new SubIndex(new File(dir, CHANGES_OPEN),
|
||||
getIndexWriterConfig(cfg, "changes_open"));
|
||||
closedIndex = new SubIndex(new File(dir, CHANGES_CLOSED),
|
||||
@@ -179,10 +182,6 @@ public class LuceneChangeIndex implements ChangeIndex, LifecycleListener {
|
||||
public ListenableFuture<Void> insert(ChangeData cd) throws IOException {
|
||||
Term id = QueryBuilder.idTerm(cd);
|
||||
Document doc = toDocument(cd);
|
||||
if (readOnly) {
|
||||
return Futures.immediateFuture(null);
|
||||
}
|
||||
|
||||
if (cd.getChange().getStatus().isOpen()) {
|
||||
return allOf(
|
||||
closedIndex.delete(id),
|
||||
@@ -199,9 +198,6 @@ public class LuceneChangeIndex implements ChangeIndex, LifecycleListener {
|
||||
public ListenableFuture<Void> replace(ChangeData cd) throws IOException {
|
||||
Term id = QueryBuilder.idTerm(cd);
|
||||
Document doc = toDocument(cd);
|
||||
if (readOnly) {
|
||||
return Futures.immediateFuture(null);
|
||||
}
|
||||
if (cd.getChange().getStatus().isOpen()) {
|
||||
return allOf(
|
||||
closedIndex.delete(id),
|
||||
@@ -217,9 +213,6 @@ public class LuceneChangeIndex implements ChangeIndex, LifecycleListener {
|
||||
@Override
|
||||
public ListenableFuture<Void> delete(ChangeData cd) throws IOException {
|
||||
Term id = QueryBuilder.idTerm(cd);
|
||||
if (readOnly) {
|
||||
return Futures.immediateFuture(null);
|
||||
}
|
||||
return allOf(
|
||||
openIndex.delete(id),
|
||||
closedIndex.delete(id));
|
||||
|
||||
@@ -34,17 +34,17 @@ import java.io.IOException;
|
||||
public class LuceneIndexModule extends LifecycleModule {
|
||||
private final boolean checkVersion;
|
||||
private final int threads;
|
||||
private final boolean readOnly;
|
||||
private final String base;
|
||||
|
||||
public LuceneIndexModule() {
|
||||
this(true, 0, false);
|
||||
this(true, 0, null);
|
||||
}
|
||||
|
||||
public LuceneIndexModule(boolean checkVersion, int threads,
|
||||
boolean readOnly) {
|
||||
String base) {
|
||||
this.checkVersion = checkVersion;
|
||||
this.threads = threads;
|
||||
this.readOnly = readOnly;
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,6 +65,6 @@ public class LuceneIndexModule extends LifecycleModule {
|
||||
@IndexExecutor ListeningScheduledExecutorService executor,
|
||||
FillArgs fillArgs) throws IOException {
|
||||
return new LuceneChangeIndex(cfg, sitePaths, indexes, executor, fillArgs,
|
||||
ChangeSchemas.getLatestRelease(), readOnly);
|
||||
ChangeSchemas.getLatestRelease(), base);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user