Search in sources :

Example 1 with IndexModuleOnInit

use of com.google.gerrit.pgm.init.index.IndexModuleOnInit in project gerrit by GerritCodeReview.

the class ElasticIndexModuleOnInit method configure.

@Override
protected void configure() {
    install(new FactoryModuleBuilder().implement(AccountIndex.class, ElasticAccountIndex.class).build(AccountIndex.Factory.class));
    install(new FactoryModuleBuilder().implement(GroupIndex.class, ElasticGroupIndex.class).build(GroupIndex.Factory.class));
    install(new IndexModuleOnInit());
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) IndexModuleOnInit(com.google.gerrit.pgm.init.index.IndexModuleOnInit)

Example 2 with IndexModuleOnInit

use of com.google.gerrit.pgm.init.index.IndexModuleOnInit 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;
}
Also used : LuceneIndexModuleOnInit(com.google.gerrit.pgm.init.index.lucene.LuceneIndexModuleOnInit) Injector(com.google.inject.Injector) ArrayList(java.util.ArrayList) Module(com.google.inject.Module) GerritServerConfigModule(com.google.gerrit.server.config.GerritServerConfigModule) IndexModule(com.google.gerrit.server.index.IndexModule) AbstractModule(com.google.inject.AbstractModule) IndexType(com.google.gerrit.index.IndexType) AbstractModule(com.google.inject.AbstractModule) IndexModuleOnInit(com.google.gerrit.pgm.init.index.IndexModuleOnInit) LuceneIndexModuleOnInit(com.google.gerrit.pgm.init.index.lucene.LuceneIndexModuleOnInit)

Example 3 with IndexModuleOnInit

use of com.google.gerrit.pgm.init.index.IndexModuleOnInit in project gerrit by GerritCodeReview.

the class LuceneIndexModuleOnInit method configure.

@Override
protected void configure() {
    install(new FactoryModuleBuilder().implement(AccountIndex.class, LuceneAccountIndex.class).build(AccountIndex.Factory.class));
    install(new FactoryModuleBuilder().implement(GroupIndex.class, LuceneGroupIndex.class).build(GroupIndex.Factory.class));
    install(new IndexModuleOnInit());
    bind(AutoFlush.class).toInstance(AutoFlush.DISABLED);
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) AutoFlush(com.google.gerrit.server.index.options.AutoFlush) IndexModuleOnInit(com.google.gerrit.pgm.init.index.IndexModuleOnInit)

Aggregations

IndexModuleOnInit (com.google.gerrit.pgm.init.index.IndexModuleOnInit)3 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)2 IndexType (com.google.gerrit.index.IndexType)1 LuceneIndexModuleOnInit (com.google.gerrit.pgm.init.index.lucene.LuceneIndexModuleOnInit)1 GerritServerConfigModule (com.google.gerrit.server.config.GerritServerConfigModule)1 IndexModule (com.google.gerrit.server.index.IndexModule)1 AutoFlush (com.google.gerrit.server.index.options.AutoFlush)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 ArrayList (java.util.ArrayList)1