use of com.google.gerrit.server.index.IndexModule in project gerrit by GerritCodeReview.
the class Reindex method createSysInjector.
private Injector createSysInjector() {
Map<String, Integer> versions = new HashMap<>();
if (changesVersion != null) {
versions.put(ChangeSchemaDefinitions.INSTANCE.getName(), changesVersion);
}
boolean replica = ReplicaUtil.isReplica(globalConfig);
List<Module> modules = new ArrayList<>();
Module indexModule;
IndexType indexType = IndexModule.getIndexType(dbInjector);
if (indexType.isLucene()) {
indexModule = LuceneIndexModule.singleVersionWithExplicitVersions(versions, threads, replica, AutoFlush.DISABLED);
} else if (indexType.isFake()) {
// compile the component in.
try {
Class<?> clazz = Class.forName("com.google.gerrit.index.testing.FakeIndexModule");
Method m = clazz.getMethod("singleVersionWithExplicitVersions", Map.class, int.class, boolean.class);
indexModule = (Module) m.invoke(null, versions, threads, replica);
} catch (NoSuchMethodException | ClassNotFoundException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("can't create index", e);
}
} else {
throw new IllegalStateException("unsupported index.type = " + indexType);
}
modules.add(indexModule);
modules.add(new AbstractModule() {
@Override
protected void configure() {
super.configure();
OptionalBinder.newOptionalBinder(binder(), IsFirstInsertForEntry.class).setBinding().toInstance(IsFirstInsertForEntry.YES);
}
});
modules.add(new BatchProgramModule(dbInjector));
modules.add(new FactoryModule() {
@Override
protected void configure() {
factory(ChangeResource.Factory.class);
}
});
return dbInjector.createChildInjector(ModuleOverloader.override(modules, LibModuleLoader.loadReindexModules(cfgInjector, versions, threads, replica)));
}
use of com.google.gerrit.server.index.IndexModule in project gerrit by GerritCodeReview.
the class ElasticIndexModule method configure.
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(AccountIndex.class, ElasticAccountIndex.class).build(AccountIndex.Factory.class));
install(new FactoryModuleBuilder().implement(ChangeIndex.class, ElasticChangeIndex.class).build(ChangeIndex.Factory.class));
install(new FactoryModuleBuilder().implement(GroupIndex.class, ElasticGroupIndex.class).build(GroupIndex.Factory.class));
install(new IndexModule(threads));
if (singleVersions == null) {
listener().to(ElasticVersionManager.class);
} else {
install(new SingleVersionModule(singleVersions));
}
}
use of com.google.gerrit.server.index.IndexModule in project gerrit by GerritCodeReview.
the class LuceneIndexModule method configure.
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(AccountIndex.class, LuceneAccountIndex.class).build(AccountIndex.Factory.class));
install(new FactoryModuleBuilder().implement(ChangeIndex.class, LuceneChangeIndex.class).build(ChangeIndex.Factory.class));
install(new FactoryModuleBuilder().implement(GroupIndex.class, LuceneGroupIndex.class).build(GroupIndex.Factory.class));
install(new IndexModule(threads));
if (singleVersions == null) {
install(new MultiVersionModule());
} else {
install(new SingleVersionModule(singleVersions));
}
}
use of com.google.gerrit.server.index.IndexModule in project gerrit by GerritCodeReview.
the class Daemon method createIndexModule.
private Module createIndexModule() {
if (indexModule != null) {
return indexModule;
}
if (indexType.isLucene()) {
return LuceneIndexModule.latestVersion(replica, AutoFlush.ENABLED);
}
if (indexType.isFake()) {
// compile the component in.
try {
Class<?> clazz = Class.forName("com.google.gerrit.index.testing.FakeIndexModule");
Method m = clazz.getMethod("latestVersion", boolean.class);
return (Module) m.invoke(null, replica);
} catch (NoSuchMethodException | ClassNotFoundException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("can't create index", e);
}
}
throw new IllegalStateException("unsupported index.type = " + indexType);
}
Aggregations