QueryProcessor: Don't inject Metrics
This allows us to continue avoiding a Guice dependency when we move this class to gerrit-index. Manual injection in this case is easy, given a MetricMaker, and it's unlikely that Metrics will grow too many more dependencies in the future. Change-Id: I951df6ea90191688fab525751680b99b28ec9d77
This commit is contained in:
parent
0b6fb95218
commit
c9ea97a0ac
|
@ -41,8 +41,6 @@ import com.google.gerrit.metrics.Timer1;
|
|||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.OrmRuntimeException;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -58,11 +56,9 @@ import java.util.stream.IntStream;
|
|||
* holding on to a single instance.
|
||||
*/
|
||||
public abstract class QueryProcessor<T> {
|
||||
@Singleton
|
||||
protected static class Metrics {
|
||||
final Timer1<String> executionTime;
|
||||
|
||||
@Inject
|
||||
Metrics(MetricMaker metricMaker) {
|
||||
Field<String> index = Field.ofString("index", "index name");
|
||||
executionTime =
|
||||
|
@ -94,14 +90,14 @@ public abstract class QueryProcessor<T> {
|
|||
private Set<String> requestedFields;
|
||||
|
||||
protected QueryProcessor(
|
||||
Metrics metrics,
|
||||
MetricMaker metricMaker,
|
||||
SchemaDefinitions<T> schemaDef,
|
||||
IndexConfig indexConfig,
|
||||
IndexCollection<?, T, ? extends Index<?, T>> indexes,
|
||||
IndexRewriter<T> rewriter,
|
||||
String limitField,
|
||||
IntSupplier permittedLimit) {
|
||||
this.metrics = metrics;
|
||||
this.metrics = new Metrics(metricMaker);
|
||||
this.schemaDef = schemaDef;
|
||||
this.indexConfig = indexConfig;
|
||||
this.indexes = indexes;
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.google.gerrit.index.IndexConfig;
|
|||
import com.google.gerrit.index.query.AndSource;
|
||||
import com.google.gerrit.index.query.IndexPredicate;
|
||||
import com.google.gerrit.index.query.Predicate;
|
||||
import com.google.gerrit.metrics.MetricMaker;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.account.AccountControl;
|
||||
import com.google.gerrit.server.account.AccountLimits;
|
||||
|
@ -52,13 +53,13 @@ public class AccountQueryProcessor extends QueryProcessor<AccountState> {
|
|||
protected AccountQueryProcessor(
|
||||
Provider<CurrentUser> userProvider,
|
||||
AccountLimits.Factory limitsFactory,
|
||||
Metrics metrics,
|
||||
MetricMaker metricMaker,
|
||||
IndexConfig indexConfig,
|
||||
AccountIndexCollection indexes,
|
||||
AccountIndexRewriter rewriter,
|
||||
AccountControl.Factory accountControlFactory) {
|
||||
super(
|
||||
metrics,
|
||||
metricMaker,
|
||||
AccountSchemaDefinitions.INSTANCE,
|
||||
indexConfig,
|
||||
indexes,
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.google.gerrit.index.IndexConfig;
|
|||
import com.google.gerrit.index.QueryOptions;
|
||||
import com.google.gerrit.index.query.IndexPredicate;
|
||||
import com.google.gerrit.index.query.Predicate;
|
||||
import com.google.gerrit.metrics.MetricMaker;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.account.AccountLimits;
|
||||
|
@ -76,7 +77,7 @@ public class ChangeQueryProcessor extends QueryProcessor<ChangeData>
|
|||
ChangeQueryProcessor(
|
||||
Provider<CurrentUser> userProvider,
|
||||
AccountLimits.Factory limitsFactory,
|
||||
Metrics metrics,
|
||||
MetricMaker metricMaker,
|
||||
IndexConfig indexConfig,
|
||||
ChangeIndexCollection indexes,
|
||||
ChangeIndexRewriter rewriter,
|
||||
|
@ -86,7 +87,7 @@ public class ChangeQueryProcessor extends QueryProcessor<ChangeData>
|
|||
DynamicMap<ChangeAttributeFactory> attributeFactories,
|
||||
PermissionBackend permissionBackend) {
|
||||
super(
|
||||
metrics,
|
||||
metricMaker,
|
||||
ChangeSchemaDefinitions.INSTANCE,
|
||||
indexConfig,
|
||||
indexes,
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.google.gerrit.index.IndexConfig;
|
|||
import com.google.gerrit.index.query.AndSource;
|
||||
import com.google.gerrit.index.query.IndexPredicate;
|
||||
import com.google.gerrit.index.query.Predicate;
|
||||
import com.google.gerrit.metrics.MetricMaker;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.account.AccountLimits;
|
||||
|
@ -53,13 +54,13 @@ public class GroupQueryProcessor extends QueryProcessor<AccountGroup> {
|
|||
protected GroupQueryProcessor(
|
||||
Provider<CurrentUser> userProvider,
|
||||
AccountLimits.Factory limitsFactory,
|
||||
Metrics metrics,
|
||||
MetricMaker metricMaker,
|
||||
IndexConfig indexConfig,
|
||||
GroupIndexCollection indexes,
|
||||
GroupIndexRewriter rewriter,
|
||||
GroupControl.GenericFactory groupControlFactory) {
|
||||
super(
|
||||
metrics,
|
||||
metricMaker,
|
||||
GroupSchemaDefinitions.INSTANCE,
|
||||
indexConfig,
|
||||
indexes,
|
||||
|
|
Loading…
Reference in New Issue