IndexConfig: Configure maxLimit from Config

An index implementation may not have an inherent upper bound to the
limit, but administrators may nonetheless want to restrict the maximum
query size at the server level for performance reasons.

Change-Id: Ic1f506e9857413ec860fe97785bff9e76b817db0
This commit is contained in:
Dave Borowitz
2015-04-22 16:43:54 -07:00
parent 8b6ec067e9
commit b82fbcb584
4 changed files with 35 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.lucene;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.index.ChangeSchemas;
import com.google.gerrit.server.index.IndexCollection;
import com.google.gerrit.server.index.IndexConfig;
@@ -26,6 +27,8 @@ import com.google.inject.Inject;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import org.eclipse.jgit.lib.Config;
public class LuceneIndexModule extends LifecycleModule {
private final Integer singleVersion;
private final int threads;
@@ -44,7 +47,6 @@ public class LuceneIndexModule extends LifecycleModule {
@Override
protected void configure() {
bind(IndexConfig.class).toInstance(IndexConfig.createDefault());
factory(LuceneChangeIndex.Factory.class);
install(new IndexModule(threads));
if (singleVersion == null && base == null) {
@@ -54,6 +56,12 @@ public class LuceneIndexModule extends LifecycleModule {
}
}
@Provides
@Singleton
IndexConfig getIndexConfig(@GerritServerConfig Config cfg) {
return IndexConfig.fromConfig(cfg);
}
private static class MultiVersionModule extends LifecycleModule {
@Override
public void configure() {