Rename ChangeBatchIndexer to SiteIndexer
The purpose of this class is to reindex the entire site, and it contains some behaviors that are really only appropriate for this scope, such as walking repositories to find lists of changed paths (rather than thrashing PatchListCache), and a synchronous call returning a results object. This is in contrast with ReindexAfterUpdate, which operates only on open changes in a single branch or project with an asynchronous interface. In fact, in each case where these different types of batch indexer can make different choices, they do, which is why they do not share implementation. The name "ChangeBatchIndexer", however, was too generic, and suggested that it might be able to fulfill the role of ReindexAfterUpdate when it can't. Change-Id: I049746f92d98c642022b3f6a14efe78afe799519
This commit is contained in:
@@ -17,9 +17,9 @@ package com.google.gerrit.lucene;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.server.index.ChangeBatchIndexer;
|
||||
import com.google.gerrit.server.index.ChangeIndex;
|
||||
import com.google.gerrit.server.index.IndexCollection;
|
||||
import com.google.gerrit.server.index.SiteIndexer;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -39,14 +39,14 @@ public class OnlineReindexer {
|
||||
}
|
||||
|
||||
private final IndexCollection indexes;
|
||||
private final ChangeBatchIndexer batchIndexer;
|
||||
private final SiteIndexer batchIndexer;
|
||||
private final ProjectCache projectCache;
|
||||
private final int version;
|
||||
|
||||
@Inject
|
||||
OnlineReindexer(
|
||||
IndexCollection indexes,
|
||||
ChangeBatchIndexer batchIndexer,
|
||||
SiteIndexer batchIndexer,
|
||||
ProjectCache projectCache,
|
||||
@Assisted int version) {
|
||||
this.indexes = indexes;
|
||||
@@ -76,7 +76,7 @@ public class OnlineReindexer {
|
||||
"not an active write schema version: %s", version);
|
||||
log.info("Starting online reindex from schema version {} to {}",
|
||||
version(indexes.getSearchIndex()), version(index));
|
||||
ChangeBatchIndexer.Result result =
|
||||
SiteIndexer.Result result =
|
||||
batchIndexer.indexAll(index, projectCache.all());
|
||||
if (!result.success()) {
|
||||
log.error("Online reindex of schema version {} failed", version(index));
|
||||
|
@@ -28,12 +28,12 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.index.ChangeBatchIndexer;
|
||||
import com.google.gerrit.server.index.ChangeIndex;
|
||||
import com.google.gerrit.server.index.ChangeSchemas;
|
||||
import com.google.gerrit.server.index.IndexCollection;
|
||||
import com.google.gerrit.server.index.IndexModule;
|
||||
import com.google.gerrit.server.index.IndexModule.IndexType;
|
||||
import com.google.gerrit.server.index.SiteIndexer;
|
||||
import com.google.gerrit.solr.SolrIndexModule;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
@@ -158,9 +158,9 @@ public class Reindex extends SiteProgram {
|
||||
}
|
||||
pm.endTask();
|
||||
|
||||
ChangeBatchIndexer batchIndexer =
|
||||
sysInjector.getInstance(ChangeBatchIndexer.class);
|
||||
ChangeBatchIndexer.Result result = batchIndexer.setNumChanges(changeCount)
|
||||
SiteIndexer batchIndexer =
|
||||
sysInjector.getInstance(SiteIndexer.class);
|
||||
SiteIndexer.Result result = batchIndexer.setNumChanges(changeCount)
|
||||
.setProgressOut(System.err)
|
||||
.setVerboseOut(verbose ? System.out : NullOutputStream.INSTANCE)
|
||||
.indexAll(index, projects);
|
||||
|
@@ -76,9 +76,9 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class ChangeBatchIndexer {
|
||||
public class SiteIndexer {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(ChangeBatchIndexer.class);
|
||||
LoggerFactory.getLogger(SiteIndexer.class);
|
||||
|
||||
public static class Result {
|
||||
private final long elapsedNanos;
|
||||
@@ -123,7 +123,7 @@ public class ChangeBatchIndexer {
|
||||
new PrintWriter(NullOutputStream.INSTANCE);
|
||||
|
||||
@Inject
|
||||
ChangeBatchIndexer(SchemaFactory<ReviewDb> schemaFactory,
|
||||
SiteIndexer(SchemaFactory<ReviewDb> schemaFactory,
|
||||
ChangeData.Factory changeDataFactory,
|
||||
GitRepositoryManager repoManager,
|
||||
@IndexExecutor(BATCH) ListeningExecutorService executor,
|
||||
@@ -137,17 +137,17 @@ public class ChangeBatchIndexer {
|
||||
this.mergeStrategy = MergeUtil.getMergeStrategy(config);
|
||||
}
|
||||
|
||||
public ChangeBatchIndexer setNumChanges(int num) {
|
||||
public SiteIndexer setNumChanges(int num) {
|
||||
numChanges = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChangeBatchIndexer setProgressOut(OutputStream out) {
|
||||
public SiteIndexer setProgressOut(OutputStream out) {
|
||||
progressOut = checkNotNull(out);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChangeBatchIndexer setVerboseOut(OutputStream out) {
|
||||
public SiteIndexer setVerboseOut(OutputStream out) {
|
||||
verboseWriter = new PrintWriter(checkNotNull(out));
|
||||
return this;
|
||||
}
|
Reference in New Issue
Block a user