IndexDefinition: Use SiteIndexer instance directly
The idea to use site indexer provider is to have lazy loading and defer the materialization of the dependencies. In running server site indexer instances for all index types are not always needed, but only if online reindexing actually takes place. But, the index initialization process currently eagerly initializes the site indexer instances and resolves the providers. How the current code organized, we can inject the site index instances directly without yet another level of indirection. The alternative approach would be to keep the provider instances in OnlineReindexer and only resolve them when online reindexing actually takes place. Change-Id: Ide48bed9ca264816463c6ab22b4b5ec2e52da7c5
This commit is contained in:
committed by
Dave Borowitz
parent
cc8de7756b
commit
2e4e33db27
@@ -15,7 +15,7 @@
|
||||
package com.google.gerrit.server.index;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
|
||||
/**
|
||||
* Definition of an index over a Gerrit data type.
|
||||
@@ -33,13 +33,13 @@ public abstract class IndexDefinition<K, V, I extends Index<K, V>> {
|
||||
private final SchemaDefinitions<V> schemaDefs;
|
||||
private final IndexCollection<K, V, I> indexCollection;
|
||||
private final IndexFactory<K, V, I> indexFactory;
|
||||
private final Provider<SiteIndexer<K, V, I>> siteIndexer;
|
||||
private final SiteIndexer<K, V, I> siteIndexer;
|
||||
|
||||
protected IndexDefinition(
|
||||
SchemaDefinitions<V> schemaDefs,
|
||||
IndexCollection<K, V, I> indexCollection,
|
||||
IndexFactory<K, V, I> indexFactory,
|
||||
Provider<SiteIndexer<K, V, I>> siteIndexer) {
|
||||
@Nullable SiteIndexer<K, V, I> siteIndexer) {
|
||||
this.schemaDefs = schemaDefs;
|
||||
this.indexCollection = indexCollection;
|
||||
this.indexFactory = indexFactory;
|
||||
@@ -66,7 +66,8 @@ public abstract class IndexDefinition<K, V, I extends Index<K, V>> {
|
||||
return indexFactory;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final SiteIndexer<K, V, I> getSiteIndexer() {
|
||||
return siteIndexer.get();
|
||||
return siteIndexer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.index.IndexDefinition;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.util.Providers;
|
||||
|
||||
public class AccountIndexDefinition
|
||||
extends IndexDefinition<Account.Id, AccountState, AccountIndex> {
|
||||
@@ -29,10 +28,6 @@ public class AccountIndexDefinition
|
||||
AccountIndexCollection indexCollection,
|
||||
AccountIndex.Factory indexFactory,
|
||||
@Nullable AllAccountsIndexer allAccountsIndexer) {
|
||||
super(
|
||||
AccountSchemaDefinitions.INSTANCE,
|
||||
indexCollection,
|
||||
indexFactory,
|
||||
Providers.of(allAccountsIndexer));
|
||||
super(AccountSchemaDefinitions.INSTANCE, indexCollection, indexFactory, allAccountsIndexer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.index.IndexDefinition;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.util.Providers;
|
||||
|
||||
public class ChangeIndexDefinition extends IndexDefinition<Change.Id, ChangeData, ChangeIndex> {
|
||||
|
||||
@@ -28,10 +27,6 @@ public class ChangeIndexDefinition extends IndexDefinition<Change.Id, ChangeData
|
||||
ChangeIndexCollection indexCollection,
|
||||
ChangeIndex.Factory indexFactory,
|
||||
@Nullable AllChangesIndexer allChangesIndexer) {
|
||||
super(
|
||||
ChangeSchemaDefinitions.INSTANCE,
|
||||
indexCollection,
|
||||
indexFactory,
|
||||
Providers.of(allChangesIndexer));
|
||||
super(ChangeSchemaDefinitions.INSTANCE, indexCollection, indexFactory, allChangesIndexer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.index.IndexDefinition;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.util.Providers;
|
||||
|
||||
public class GroupIndexDefinition
|
||||
extends IndexDefinition<AccountGroup.UUID, AccountGroup, GroupIndex> {
|
||||
@@ -28,10 +27,6 @@ public class GroupIndexDefinition
|
||||
GroupIndexCollection indexCollection,
|
||||
GroupIndex.Factory indexFactory,
|
||||
@Nullable AllGroupsIndexer allGroupsIndexer) {
|
||||
super(
|
||||
GroupSchemaDefinitions.INSTANCE,
|
||||
indexCollection,
|
||||
indexFactory,
|
||||
Providers.of(allGroupsIndexer));
|
||||
super(GroupSchemaDefinitions.INSTANCE, indexCollection, indexFactory, allGroupsIndexer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user