Search in sources :

Example 1 with IndexManagerOnInit

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

the class BaseInit method run.

@Override
public int run() throws Exception {
    final SiteInit init = createSiteInit();
    if (beforeInit(init)) {
        return 0;
    }
    init.flags.autoStart = getAutoStart() && init.site.isNew;
    init.flags.dev = isDev() && init.site.isNew;
    init.flags.skipPlugins = skipPlugins();
    init.flags.deleteCaches = getDeleteCaches();
    init.flags.isNew = init.site.isNew;
    final SiteRun run;
    try {
        init.initializer.run();
        init.flags.deleteOnFailure = false;
        Injector sysInjector = createSysInjector(init);
        IndexManagerOnInit indexManager = sysInjector.getInstance(IndexManagerOnInit.class);
        try {
            indexManager.start();
            run = createSiteRun(init);
            try {
                run.upgradeSchema();
            } catch (StorageException e) {
                String msg = "Couldn't upgrade schema. Expected if slave and read-only database";
                System.err.println(msg);
                logger.atSevere().withCause(e).log("%s", msg);
            }
            init.initializer.postRun(sysInjector);
        } finally {
            indexManager.stop();
        }
    } catch (Exception | Error failure) {
        if (init.flags.deleteOnFailure) {
            recursiveDelete(getSitePath());
        }
        throw failure;
    }
    System.err.println("Initialized " + getSitePath().toRealPath().normalize());
    afterInit(run);
    return 0;
}
Also used : IndexManagerOnInit(com.google.gerrit.pgm.init.index.IndexManagerOnInit) Injector(com.google.inject.Injector) StorageException(com.google.gerrit.exceptions.StorageException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) StorageException(com.google.gerrit.exceptions.StorageException) IOException(java.io.IOException) CreationException(com.google.inject.CreationException)

Aggregations

StorageException (com.google.gerrit.exceptions.StorageException)1 IndexManagerOnInit (com.google.gerrit.pgm.init.index.IndexManagerOnInit)1 CreationException (com.google.inject.CreationException)1 Injector (com.google.inject.Injector)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1