SiteRebuilder: Build rebuilder with a builder
We already have several configuration options and we're going to add more. Use the normal Builder pattern to separate option-setting from running, and make all fields in SiteRebuilder final. The downside is because of Guice we need to create the builder with a siteRebuilderBuilderProvider and manually copy arguments to the SiteRebuilder constructor. Oh well, what can you do. (And we are later planning on renaming this class so at least it won't be a RebuilderBuilder for long.) Add another SiteIndexer-like option, the stream for progress output. Change the standalone program to write to stderr instead of stdout, also for consistency with SiteIndexer. Ensure that all output goes either to the progress monitor or the log, rather than writing directly to stdout. Document the supported options. Change-Id: Iceaf75cd94d68bb751e97df1769c41a1e97228aa
This commit is contained in:
@@ -33,6 +33,7 @@ import com.google.gerrit.server.notedb.NotesMigration;
|
||||
import com.google.gerrit.server.notedb.rebuild.SiteRebuilder;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provider;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.kohsuke.args4j.Option;
|
||||
@@ -53,7 +54,7 @@ public class RebuildNoteDb extends SiteProgram {
|
||||
private Injector dbInjector;
|
||||
private Injector sysInjector;
|
||||
|
||||
@Inject private SiteRebuilder.Factory rebuilderFactory;
|
||||
@Inject private Provider<SiteRebuilder.Builder> rebuilderBuilderProvider;
|
||||
|
||||
@Inject private NotesMigration notesMigration;
|
||||
|
||||
@@ -76,13 +77,14 @@ public class RebuildNoteDb extends SiteProgram {
|
||||
sysManager.add(sysInjector);
|
||||
sysManager.start();
|
||||
|
||||
System.out.println("Rebuilding the NoteDb");
|
||||
|
||||
try (SiteRebuilder rebuilder =
|
||||
rebuilderFactory.create(
|
||||
threads,
|
||||
projects.stream().map(Project.NameKey::new).collect(toList()),
|
||||
changes.stream().map(Change.Id::new).collect(toList()))) {
|
||||
rebuilderBuilderProvider
|
||||
.get()
|
||||
.setThreads(threads)
|
||||
.setProgressOut(System.err)
|
||||
.setProjects(projects.stream().map(Project.NameKey::new).collect(toList()))
|
||||
.setChanges(changes.stream().map(Change.Id::new).collect(toList()))
|
||||
.build()) {
|
||||
return rebuilder.rebuild() ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user