Simplify Init for Elasticsearch
Perform reindex operation for all indexes on init for elasticsearch index. This change allows for starting an elasticsearch index with only the init command, similar to a Lucene index. Remove reindex operation on ElasticReindexIT, since with this change performing a reindex manually is no longer needed. Test plan: Run InitIT, ElasticReindexIT and ReindexIT. Feature: Issue 12704 Change-Id: If7741771e25a6063c5116ab2bce39fbe0e0ea93b
This commit is contained in:
@@ -32,6 +32,9 @@ import com.google.gerrit.pgm.util.ErrorLogFile;
|
||||
import com.google.gerrit.server.config.GerritServerConfigModule;
|
||||
import com.google.gerrit.server.config.SitePath;
|
||||
import com.google.gerrit.server.index.GerritIndexStatus;
|
||||
import com.google.gerrit.server.index.account.AccountSchemaDefinitions;
|
||||
import com.google.gerrit.server.index.change.ChangeSchemaDefinitions;
|
||||
import com.google.gerrit.server.index.group.GroupSchemaDefinitions;
|
||||
import com.google.gerrit.server.ioutil.HostPlatform;
|
||||
import com.google.gerrit.server.securestore.SecureStoreClassName;
|
||||
import com.google.gerrit.server.util.ReplicaUtil;
|
||||
@@ -90,7 +93,7 @@ public class Init extends BaseInit {
|
||||
|
||||
@Inject Browser browser;
|
||||
|
||||
private boolean projectsIndexExists;
|
||||
private GerritIndexStatus indexStatus;
|
||||
|
||||
public Init() {
|
||||
super(new WarDistribution(), null);
|
||||
@@ -104,7 +107,7 @@ public class Init extends BaseInit {
|
||||
|
||||
@Override
|
||||
protected boolean beforeInit(SiteInit init) throws Exception {
|
||||
projectsIndexExists = new GerritIndexStatus(init.site).exists(ProjectSchemaDefinitions.NAME);
|
||||
indexStatus = new GerritIndexStatus(init.site);
|
||||
ErrorLogFile.errorOnlyConsole();
|
||||
|
||||
if (!skipPlugins) {
|
||||
@@ -133,6 +136,12 @@ public class Init extends BaseInit {
|
||||
|
||||
@Override
|
||||
protected void afterInit(SiteRun run) throws Exception {
|
||||
List<SchemaDefinitions<?>> schemaDefs =
|
||||
ImmutableList.of(
|
||||
AccountSchemaDefinitions.INSTANCE,
|
||||
ChangeSchemaDefinitions.INSTANCE,
|
||||
GroupSchemaDefinitions.INSTANCE,
|
||||
ProjectSchemaDefinitions.INSTANCE);
|
||||
List<Module> modules = new ArrayList<>();
|
||||
modules.add(
|
||||
new AbstractModule() {
|
||||
@@ -147,8 +156,12 @@ public class Init extends BaseInit {
|
||||
});
|
||||
modules.add(new GerritServerConfigModule());
|
||||
Guice.createInjector(modules).injectMembers(this);
|
||||
if (!ReplicaUtil.isReplica(run.flags.cfg) && !projectsIndexExists) {
|
||||
reindex(ProjectSchemaDefinitions.INSTANCE);
|
||||
if (!ReplicaUtil.isReplica(run.flags.cfg)) {
|
||||
for (SchemaDefinitions<?> schemaDef : schemaDefs) {
|
||||
if (!indexStatus.exists(schemaDef.getName())) {
|
||||
reindex(schemaDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
start(run);
|
||||
}
|
||||
|
Reference in New Issue
Block a user