Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void run(final org.neo4j.io.fs.FileSystemAbstraction fs, final java.io.File storeDirectory, org.neo4j.kernel.configuration.Config config, org.neo4j.logging.LogProvider userLogProvider) throws Exception
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public static void Run(FileSystemAbstraction fs, File storeDirectory, Config config, LogProvider userLogProvider)
        {
            StoreLogService logService = StoreLogService.withUserLogProvider(userLogProvider).withInternalLog(config.Get(store_internal_log_path)).build(fs);

            VisibleMigrationProgressMonitor progressMonitor = new VisibleMigrationProgressMonitor(logService.GetUserLog(typeof(StoreMigration)));

            LifeSupport life = new LifeSupport();

            life.Add(logService);

            // Add participants from kernel extensions...
            DefaultExplicitIndexProvider migrationIndexProvider = new DefaultExplicitIndexProvider();

            Log          log          = userLogProvider.GetLog(typeof(StoreMigration));
            JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler();

            try
            {
                using (PageCache pageCache = createPageCache(fs, config, jobScheduler))
                {
                    Dependencies deps     = new Dependencies();
                    Monitors     monitors = new Monitors();
                    deps.SatisfyDependencies(fs, config, migrationIndexProvider, pageCache, logService, monitors, RecoveryCleanupWorkCollector.immediate());

                    KernelContext            kernelContext    = new SimpleKernelContext(storeDirectory, DatabaseInfo.UNKNOWN, deps);
                    DatabaseKernelExtensions kernelExtensions = life.Add(new DatabaseKernelExtensions(kernelContext, GraphDatabaseDependencies.newDependencies().kernelExtensions(), deps, ignore()));

                    DatabaseLayout databaseLayout = DatabaseLayout.of(storeDirectory);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles = org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.activeFilesBuilder(databaseLayout, fs, pageCache).withConfig(config).build();
                    LogFiles       logFiles    = LogFilesBuilder.activeFilesBuilder(databaseLayout, fs, pageCache).withConfig(config).build();
                    LogTailScanner tailScanner = new LogTailScanner(logFiles, new VersionAwareLogEntryReader <Org.Neo4j.Kernel.impl.transaction.log.ReadableClosablePositionAwareChannel>(), monitors);

                    DefaultIndexProviderMap indexProviderMap = life.Add(new DefaultIndexProviderMap(kernelExtensions, config));

                    // Add the kernel store migrator
                    life.Start();

                    long             startTime = DateTimeHelper.CurrentUnixTimeMillis();
                    DatabaseMigrator migrator  = new DatabaseMigrator(progressMonitor, fs, config, logService, indexProviderMap, migrationIndexProvider, pageCache, RecordFormatSelector.selectForConfig(config, userLogProvider), tailScanner, jobScheduler);
                    migrator.Migrate(databaseLayout);

                    // Append checkpoint so the last log entry will have the latest version
                    AppendCheckpoint(logFiles, tailScanner);

                    long duration = DateTimeHelper.CurrentUnixTimeMillis() - startTime;
                    log.Info(format("Migration completed in %d s%n", duration / 1000));
                }
            }
            catch (Exception e)
            {
                throw new StoreUpgrader.UnableToUpgradeException("Failure during upgrade", e);
            }
            finally
            {
                life.Shutdown();
                jobScheduler.close();
            }
        }
Ejemplo n.º 2
0
        private static LogService LogService(FileSystemAbstraction fileSystem, Config config)
        {
            File logFile = config.Get(store_internal_log_path);

            try
            {
                ZoneId zoneId = config.Get(GraphDatabaseSettings.db_timezone).ZoneId;
                FormattedLogProvider logProvider = FormattedLogProvider.withZoneId(zoneId).toOutputStream(System.out);
                return(StoreLogService.withUserLogProvider(logProvider).withInternalLog(logFile).build(fileSystem));
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
        }