Search in sources :

Example 6 with IndexType

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;
}
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 7 with IndexType

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);
}
Also used : GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) Config(org.eclipse.jgit.lib.Config) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) IndexType(com.google.gerrit.index.IndexType)

Aggregations

IndexType (com.google.gerrit.index.IndexType)7 GerritServerConfig (com.google.gerrit.server.config.GerritServerConfig)4 AbstractModule (com.google.inject.AbstractModule)4 Config (org.eclipse.jgit.lib.Config)3 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)2 GlobalPluginConfig (com.google.gerrit.acceptance.config.GlobalPluginConfig)2 GerritRuntime (com.google.gerrit.server.config.GerritRuntime)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 MoreExecutors.newDirectExecutorService (com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService)1 ReindexGroupsAtStartupModule (com.google.gerrit.acceptance.ReindexGroupsAtStartup.ReindexGroupsAtStartupModule)1 ReindexProjectsAtStartupModule (com.google.gerrit.acceptance.ReindexProjectsAtStartup.ReindexProjectsAtStartupModule)1 ProjectOperations (com.google.gerrit.acceptance.testsuite.project.ProjectOperations)1 AuthModule (com.google.gerrit.auth.AuthModule)1 FactoryModule (com.google.gerrit.extensions.config.FactoryModule)1 DynamicMap (com.google.gerrit.extensions.registration.DynamicMap)1 ServerInformation (com.google.gerrit.extensions.systemstatus.ServerInformation)1 GpgModule (com.google.gerrit.gpg.GpgModule)1 OAuthRestModule (com.google.gerrit.httpd.auth.restapi.OAuthRestModule)1 LuceneIndexModule (com.google.gerrit.lucene.LuceneIndexModule)1 DisabledMetricMaker (com.google.gerrit.metrics.DisabledMetricMaker)1