Example #1
0
 public DatabaseMigrator(MigrationProgressMonitor progressMonitor, FileSystemAbstraction fs, Config config, LogService logService, IndexProviderMap indexProviderMap, ExplicitIndexProvider indexProvider, PageCache pageCache, RecordFormats format, LogTailScanner tailScanner, JobScheduler jobScheduler)
 {
     this._progressMonitor = progressMonitor;
     this._fs                    = fs;
     this._config                = config;
     this._logService            = logService;
     this._indexProviderMap      = indexProviderMap;
     this._explicitIndexProvider = indexProvider;
     this._pageCache             = pageCache;
     this._format                = format;
     this._tailScanner           = tailScanner;
     this._jobScheduler          = jobScheduler;
 }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public boolean isRecoveryRequiredAt(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException
        public virtual bool IsRecoveryRequiredAt(DatabaseLayout databaseLayout)
        {
            // We need config to determine where the logical log files are
            if (!NeoStores.isStorePresent(_pageCache, databaseLayout))
            {
                return(false);
            }

            LogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogFiles       logFiles    = LogFilesBuilder.activeFilesBuilder(databaseLayout, _fs, _pageCache).withConfig(_config).withLogEntryReader(reader).build();
            LogTailScanner tailScanner = new LogTailScanner(logFiles, reader, _monitors);

            return((new RecoveryStartInformationProvider(tailScanner, NO_MONITOR)).get().RecoveryRequired);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void check(org.neo4j.kernel.recovery.LogTailScanner tailScanner, org.neo4j.kernel.configuration.Config config) throws org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException
        public static void Check(LogTailScanner tailScanner, Config config)
        {
            if (!config.Get(GraphDatabaseSettings.allow_upgrade))
            {
                // The user doesn't want us to upgrade the store.
                LogEntryVersion latestLogEntryVersion = tailScanner.TailInformation.latestLogEntryVersion;
                if (latestLogEntryVersion != null && LogEntryVersion.moreRecentVersionExists(latestLogEntryVersion))
                {
                    string message = "The version you're upgrading to is using a new transaction log format. This is a " +
                                     "non-reversible upgrade and you wont be able to downgrade after starting";

                    throw new UpgradeNotAllowedByConfigurationException(message);
                }
            }
        }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void appendCheckpoint(org.neo4j.kernel.impl.transaction.log.entry.LogEntryVersion logVersion) throws java.io.IOException
        private void AppendCheckpoint(LogEntryVersion logVersion)
        {
            PageCache pageCache = _pageCacheRule.getPageCache(_fs);
            VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogFiles       logFiles    = LogFilesBuilder.activeFilesBuilder(_storeDirectory.databaseLayout(), _fs, pageCache).withLogEntryReader(logEntryReader).build();
            LogTailScanner tailScanner = new LogTailScanner(logFiles, logEntryReader, new Monitors());

            LogTailScanner.LogTailInformation tailInformation = tailScanner.TailInformation;

            using (Lifespan lifespan = new Lifespan(logFiles))
            {
                FlushablePositionAwareChannel channel = logFiles.LogFile.Writer;

                LogPosition logPosition = tailInformation.LastCheckPoint.LogPosition;

                // Fake record
                channel.Put(logVersion.byteCode()).put(CHECK_POINT).putLong(logPosition.LogVersion).putLong(logPosition.ByteOffset);

                channel.PrepareForFlush().flush();
            }
        }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void removeCheckPointFromTxLog(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File databaseDirectory) throws java.io.IOException
        public static void RemoveCheckPointFromTxLog(FileSystemAbstraction fileSystem, File databaseDirectory)
        {
            LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseDirectory, fileSystem).build();
            LogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogTailScanner tailScanner = new LogTailScanner(logFiles, logEntryReader, new Monitors());

            LogTailScanner.LogTailInformation logTailInformation = tailScanner.TailInformation;

            if (logTailInformation.CommitsAfterLastCheckpoint())
            {
                // done already
                return;
            }

            // let's assume there is at least a checkpoint
            assertNotNull(logTailInformation.LastCheckPoint);

            LogPosition logPosition = logTailInformation.LastCheckPoint.LogPosition;
            File        logFile     = logFiles.GetLogFileForVersion(logPosition.LogVersion);

            fileSystem.Truncate(logFile, logPosition.ByteOffset);
        }