Refactor reindexProjects in Init to be general
Refactor reindexProjects method in Init to allow reindex for all indexes rather than only for Projects. This is especially useful for Elasticsearch since it allows us to reindex all indexes before starting the site. Change-Id: I17d532b1beac3465aac53fbda778e7838687511c
This commit is contained in:
@@ -22,6 +22,7 @@ import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.common.IoUtil;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.common.PluginData;
|
||||
import com.google.gerrit.index.SchemaDefinitions;
|
||||
import com.google.gerrit.index.project.ProjectSchemaDefinitions;
|
||||
import com.google.gerrit.pgm.init.BaseInit;
|
||||
import com.google.gerrit.pgm.init.Browser;
|
||||
@@ -147,7 +148,7 @@ public class Init extends BaseInit {
|
||||
modules.add(new GerritServerConfigModule());
|
||||
Guice.createInjector(modules).injectMembers(this);
|
||||
if (!ReplicaUtil.isReplica(run.flags.cfg) && !projectsIndexExists) {
|
||||
reindexProjects();
|
||||
reindex(ProjectSchemaDefinitions.INSTANCE);
|
||||
}
|
||||
start(run);
|
||||
}
|
||||
@@ -260,8 +261,7 @@ public class Init extends BaseInit {
|
||||
}
|
||||
}
|
||||
|
||||
private void reindexProjects() throws Exception {
|
||||
// Reindex all projects, so that we bootstrap the project index for new installations
|
||||
private void reindex(SchemaDefinitions<?> schemaDef) throws Exception {
|
||||
List<String> reindexArgs =
|
||||
ImmutableList.of(
|
||||
"--site-path",
|
||||
@@ -269,8 +269,9 @@ public class Init extends BaseInit {
|
||||
"--threads",
|
||||
Integer.toString(1),
|
||||
"--index",
|
||||
ProjectSchemaDefinitions.NAME);
|
||||
getConsoleUI().message("Init complete, reindexing projects with:");
|
||||
schemaDef.getName());
|
||||
getConsoleUI()
|
||||
.message(String.format("Init complete, reindexing %s with:", schemaDef.getName()));
|
||||
getConsoleUI().message(" reindex " + reindexArgs.stream().collect(joining(" ")));
|
||||
Reindex reindexPgm = new Reindex();
|
||||
reindexPgm.main(reindexArgs.stream().toArray(String[]::new));
|
||||
|
Reference in New Issue
Block a user