use of com.google.gerrit.pgm.util.BatchProgramModule 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)));
}
Aggregations