use of com.google.gerrit.index.IndexType in project gerrit by GerritCodeReview.
the class BaseInit method createSysInjector.
private Injector createSysInjector(SiteInit init) {
if (sysInjector == null) {
final List<Module> modules = new ArrayList<>();
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(ConsoleUI.class).toInstance(init.ui);
bind(InitFlags.class).toInstance(init.flags);
}
});
Injector dbInjector = createDbInjector();
IndexType indexType = IndexModule.getIndexType(dbInjector);
if (indexType.isLucene()) {
modules.add(new LuceneIndexModuleOnInit());
} else if (indexType.isFake()) {
try {
Class<?> clazz = Class.forName("com.google.gerrit.index.testing.FakeIndexModuleOnInit");
Module indexOnInitModule = (Module) clazz.getDeclaredConstructor().newInstance();
modules.add(indexOnInitModule);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalStateException("unable to create fake index", e);
}
modules.add(new IndexModuleOnInit());
} else {
throw new IllegalStateException("unsupported index.type = " + indexType);
}
sysInjector = dbInjector.createChildInjector(modules);
}
return sysInjector;
}
use of com.google.gerrit.index.IndexType in project gerrit by GerritCodeReview.
the class IndexModule method getIndexType.
/**
* Type of secondary index.
*/
public static IndexType getIndexType(Injector injector) {
Config cfg = injector.getInstance(Key.get(Config.class, GerritServerConfig.class));
String configValue = cfg != null ? cfg.getString("index", null, "type") : null;
return new IndexType(configValue);
}
Aggregations