示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCommunicateWhatCausesInabilityToUpgrade()
            public virtual void ShouldCommunicateWhatCausesInabilityToUpgrade()
            {
                // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final UpgradableDatabase upgradableDatabase = getUpgradableDatabase();
                UpgradableDatabase upgradableDatabase = UpgradableDatabase;

                try
                {
                    // when
                    upgradableDatabase.CheckUpgradable(DatabaseLayout);
                    fail("should not have been able to upgrade");
                }
                catch (StoreUpgrader.UnexpectedUpgradingStoreVersionException e)
                {
                    // then
                    assertEquals(string.format(MESSAGE, Version, upgradableDatabase.CurrentVersion(), Version.Neo4jVersion), e.Message);
                }
                catch (StoreUpgrader.UnexpectedUpgradingStoreFormatException e)
                {
                    // then
                    assertNotSame(StandardFormatFamily.INSTANCE, RecordFormatSelector.selectForVersion(Version).FormatFamily);
                    assertEquals(string.format(StoreUpgrader.UnexpectedUpgradingStoreFormatException.MESSAGE, GraphDatabaseSettings.record_format.name()), e.Message);
                }
            }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void notParticipatingParticipantsAreNotPartOfMigration() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void NotParticipatingParticipantsAreNotPartOfMigration()
        {
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);
            StoreUpgrader      storeUpgrader      = NewUpgrader(upgradableDatabase, pageCache);

            assertThat(storeUpgrader.Participants, hasSize(3));
        }
示例#3
0
 public StoreUpgrader(UpgradableDatabase upgradableDatabase, MigrationProgressMonitor progressMonitor, Config config, FileSystemAbstraction fileSystem, PageCache pageCache, LogProvider logProvider)
 {
     this._upgradableDatabase = upgradableDatabase;
     this._progressMonitor    = progressMonitor;
     this._fileSystem         = fileSystem;
     this._config             = config;
     this._pageCache          = pageCache;
     this._logProvider        = logProvider;
     this._log = logProvider.getLog(this.GetType());
 }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDetectOldVersionAsDifferentFromCurrent()
            public virtual void ShouldDetectOldVersionAsDifferentFromCurrent()
            {
                // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final UpgradableDatabase upgradableDatabase = getUpgradableDatabase();
                UpgradableDatabase upgradableDatabase = UpgradableDatabase;
                // when
                bool currentVersion = upgradableDatabase.HasCurrentVersion(DatabaseLayout);

                // then
                assertFalse(currentVersion);
            }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void upgradeShouldNotLeaveLeftoverAndMigrationDirs() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpgradeShouldNotLeaveLeftoverAndMigrationDirs()
        {
            // Given
            _fileSystem.deleteFile(_databaseLayout.file(INTERNAL_LOG_FILE));
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            // When
            NewUpgrader(upgradableDatabase, _allowMigrateConfig, pageCache).migrateIfNeeded(_databaseLayout);

            // Then
            assertThat(MigrationHelperDirs(), @is(emptyCollectionOf(typeof(File))));
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAcceptTheStoresInTheSampleDatabaseAsBeingEligibleForUpgrade()
            public virtual void ShouldAcceptTheStoresInTheSampleDatabaseAsBeingEligibleForUpgrade()
            {
                // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final UpgradableDatabase upgradableDatabase = getUpgradableDatabase();
                UpgradableDatabase upgradableDatabase = UpgradableDatabase;

                // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final boolean result = storeFilesUpgradable(databaseLayout, upgradableDatabase);
                bool result = StoreFilesUpgradable(DatabaseLayout, upgradableDatabase);

                // then
                assertTrue(result);
            }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void upgradeShouldGiveProgressMonitorProgressMessages() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpgradeShouldGiveProgressMonitorProgressMessages()
        {
            // Given
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            // When
            AssertableLogProvider logProvider = new AssertableLogProvider();

            NewUpgrader(upgradableDatabase, pageCache, _allowMigrateConfig, new VisibleMigrationProgressMonitor(logProvider.GetLog("test"))).migrateIfNeeded(_databaseLayout);

            // Then
            AssertableLogProvider.MessageMatcher messageMatcher = logProvider.RawMessageMatcher();
            messageMatcher.AssertContains("Store files");
            messageMatcher.AssertContains("Indexes");
            messageMatcher.AssertContains("Counts store");
            messageMatcher.AssertContains("Successfully finished");
        }
示例#8
0
        /// <summary>
        /// Performs construction of <seealso cref="StoreUpgrader"/> and all of the necessary participants and performs store
        /// migration if that is required. </summary>
        /// <param name="directoryStructure"> database to migrate </param>
        public virtual void Migrate(DatabaseLayout directoryStructure)
        {
            LogProvider        logProvider        = _logService.InternalLogProvider;
            UpgradableDatabase upgradableDatabase = new UpgradableDatabase(new StoreVersionCheck(_pageCache), _format, _tailScanner);
            StoreUpgrader      storeUpgrader      = new StoreUpgrader(upgradableDatabase, _progressMonitor, _config, _fs, _pageCache, logProvider);

            ExplicitIndexMigrator        explicitIndexMigrator        = new ExplicitIndexMigrator(_fs, _explicitIndexProvider, logProvider);
            StoreMigrator                storeMigrator                = new StoreMigrator(_fs, _pageCache, _config, _logService, _jobScheduler);
            NativeLabelScanStoreMigrator nativeLabelScanStoreMigrator = new NativeLabelScanStoreMigrator(_fs, _pageCache, _config);
            CountsMigrator               countsMigrator               = new CountsMigrator(_fs, _pageCache, _config);

            _indexProviderMap.accept(provider => storeUpgrader.addParticipant(provider.storeMigrationParticipant(_fs, _pageCache)));
            storeUpgrader.AddParticipant(explicitIndexMigrator);
            storeUpgrader.AddParticipant(storeMigrator);
            storeUpgrader.AddParticipant(nativeLabelScanStoreMigrator);
            storeUpgrader.AddParticipant(countsMigrator);
            storeUpgrader.MigrateIfNeeded(directoryStructure);
        }
示例#9
0
        private StoreUpgrader NewUpgrader(UpgradableDatabase upgradableDatabase, PageCache pageCache, Config config, MigrationProgressMonitor progressMonitor)
        {
            NullLogService      instance        = NullLogService.Instance;
            StoreMigrator       defaultMigrator = new StoreMigrator(_fileSystem, pageCache, TuningConfig, instance, _jobScheduler);
            CountsMigrator      countsMigrator  = new CountsMigrator(_fileSystem, pageCache, TuningConfig);
            SchemaIndexMigrator indexMigrator   = new SchemaIndexMigrator(_fileSystem, IndexProvider.EMPTY);

            StoreUpgrader upgrader = new StoreUpgrader(upgradableDatabase, progressMonitor, config, _fileSystem, pageCache, NullLogProvider.Instance);

            upgrader.AddParticipant(indexMigrator);
            upgrader.AddParticipant(AbstractStoreMigrationParticipant.NOT_PARTICIPATING);
            upgrader.AddParticipant(AbstractStoreMigrationParticipant.NOT_PARTICIPATING);
            upgrader.AddParticipant(AbstractStoreMigrationParticipant.NOT_PARTICIPATING);
            upgrader.AddParticipant(AbstractStoreMigrationParticipant.NOT_PARTICIPATING);
            upgrader.AddParticipant(defaultMigrator);
            upgrader.AddParticipant(countsMigrator);
            return(upgrader);
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess()
        {
            PageCache pageCache             = _pageCacheRule.getPageCache(_fileSystem);
            Config    deniedMigrationConfig = Config.defaults(GraphDatabaseSettings.allow_upgrade, "false");

            deniedMigrationConfig.Augment(GraphDatabaseSettings.record_format, Standard.LATEST_NAME);

            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            try
            {
                NewUpgrader(upgradableDatabase, deniedMigrationConfig, pageCache).migrateIfNeeded(_databaseLayout);
                fail("Should throw exception");
            }
            catch (UpgradeNotAllowedByConfigurationException)
            {
                // expected
            }
        }
示例#11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRejectStoresIfDBIsNotShutdownCleanly() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void ShouldRejectStoresIfDBIsNotShutdownCleanly()
            {
                // checkpoint has been introduced in 2.3
                Assume.assumeTrue(StandardV2_3.STORE_VERSION.Equals(Version));

                // given
                removeCheckPointFromTxLog(FileSystem, DatabaseLayout.databaseDirectory());
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final UpgradableDatabase upgradableDatabase = getUpgradableDatabase();
                UpgradableDatabase upgradableDatabase = UpgradableDatabase;

                // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final boolean result = storeFilesUpgradable(databaseLayout, upgradableDatabase);
                bool result = StoreFilesUpgradable(DatabaseLayout, upgradableDatabase);

                // then
                assertFalse(result);
            }
示例#12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldContinueMovingFilesIfUpgradeCancelledWhileMoving() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldContinueMovingFilesIfUpgradeCancelledWhileMoving()
        {
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            string versionToMigrateTo   = upgradableDatabase.CurrentVersion();
            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(_databaseLayout).storeVersion();

            {
                // GIVEN
                StoreUpgrader upgrader       = NewUpgrader(upgradableDatabase, _allowMigrateConfig, pageCache);
                string        failureMessage = "Just failing";
                upgrader.AddParticipant(ParticipantThatWillFailWhenMoving(failureMessage));

                // WHEN
                try
                {
                    upgrader.MigrateIfNeeded(_databaseLayout);
                    fail("should have thrown");
                }
                catch (UnableToUpgradeException e)
                {                         // THEN
                    assertTrue(e.InnerException is IOException);
                    assertEquals(failureMessage, e.InnerException.Message);
                }
            }

            {
                // AND WHEN

                StoreUpgrader             upgrader             = NewUpgrader(upgradableDatabase, pageCache);
                StoreMigrationParticipant observingParticipant = Mockito.mock(typeof(StoreMigrationParticipant));
                upgrader.AddParticipant(observingParticipant);
                upgrader.MigrateIfNeeded(_databaseLayout);

                // THEN
                verify(observingParticipant, Mockito.never()).migrate(any(typeof(DatabaseLayout)), any(typeof(DatabaseLayout)), any(typeof(ProgressReporter)), eq(versionToMigrateFrom), eq(versionToMigrateTo));
                verify(observingParticipant, Mockito.times(1)).moveMigratedFiles(any(typeof(DatabaseLayout)), any(typeof(DatabaseLayout)), eq(versionToMigrateFrom), eq(versionToMigrateTo));

                verify(observingParticipant, Mockito.times(1)).cleanup(any(typeof(DatabaseLayout)));
            }
        }
示例#13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void upgraderShouldCleanupLegacyLeftoverAndMigrationDirs() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpgraderShouldCleanupLegacyLeftoverAndMigrationDirs()
        {
            // Given
            _fileSystem.deleteFile(_databaseLayout.file(INTERNAL_LOG_FILE));
            _fileSystem.mkdir(_databaseLayout.file(StoreUpgrader.MIGRATION_DIRECTORY));
            _fileSystem.mkdir(_databaseLayout.file(StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY));
            _fileSystem.mkdir(_databaseLayout.file(StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_1"));
            _fileSystem.mkdir(_databaseLayout.file(StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_2"));
            _fileSystem.mkdir(_databaseLayout.file(StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_42"));
            PageCache pageCache = _pageCacheRule.getPageCache(_fileSystem);

            // When
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);
            StoreUpgrader      storeUpgrader      = NewUpgrader(upgradableDatabase, pageCache);

            storeUpgrader.MigrateIfNeeded(_databaseLayout);

            // Then
            assertThat(MigrationHelperDirs(), @is(emptyCollectionOf(typeof(File))));
        }
示例#14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters(name = "Migrate: {0}->{1}") public static Iterable<Object[]> data() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public static IEnumerable <object[]> Data()
        {
            FileSystemAbstraction fs            = _fileSystemRule.get();
            PageCache             pageCache     = _pageCacheRule.getPageCache(fs);
            TestDirectory         testDirectory = TestDirectory.testDirectory();

            testDirectory.PrepareDirectory(typeof(StoreMigrationIT), "migration");
            DatabaseLayout    databaseLayout    = testDirectory.DatabaseLayout();
            StoreVersionCheck storeVersionCheck = new StoreVersionCheck(pageCache);
            VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogFiles             logFiles      = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.DatabaseDirectory(), fs).withLogEntryReader(logEntryReader).build();
            LogTailScanner       tailScanner   = new LogTailScanner(logFiles, logEntryReader, new Monitors());
            IList <object[]>     data          = new List <object[]>();
            List <RecordFormats> recordFormats = new List <RecordFormats>();

            RecordFormatSelector.allFormats().forEach(f => addIfNotThere(f, recordFormats));
            foreach (RecordFormats toFormat in recordFormats)
            {
                UpgradableDatabase upgradableDatabase = new UpgradableDatabase(storeVersionCheck, toFormat, tailScanner);
                foreach (RecordFormats fromFormat in recordFormats)
                {
                    try
                    {
                        CreateDb(fromFormat, databaseLayout.DatabaseDirectory());
                        if (!upgradableDatabase.HasCurrentVersion(databaseLayout))
                        {
                            upgradableDatabase.CheckUpgradable(databaseLayout);
                            data.Add(new object[] { fromFormat, toFormat });
                        }
                    }
                    catch (Exception)
                    {
                        //This means that the combination is not migratable.
                    }
                    fs.DeleteRecursively(databaseLayout.DatabaseDirectory());
                }
            }

            return(data);
        }
示例#15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRefuseToUpgradeIfAllOfTheStoresWereNotShutDownCleanly() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRefuseToUpgradeIfAllOfTheStoresWereNotShutDownCleanly()
        {
            File comparisonDirectory = _directory.directory("shouldRefuseToUpgradeIfAllOfTheStoresWereNotShutDownCleanly-comparison");

            removeCheckPointFromTxLog(_fileSystem, _databaseLayout.databaseDirectory());
            _fileSystem.deleteRecursively(comparisonDirectory);
            _fileSystem.copyRecursively(_databaseLayout.databaseDirectory(), comparisonDirectory);
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            try
            {
                NewUpgrader(upgradableDatabase, pageCache).migrateIfNeeded(_databaseLayout);
                fail("Should throw exception");
            }
            catch (StoreUpgrader.UnableToUpgradeException)
            {
                // expected
            }

            verifyFilesHaveSameContent(_fileSystem, comparisonDirectory, _databaseLayout.databaseDirectory());
        }
示例#16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void upgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId()
        {
            // Given
            _fileSystem.deleteFile(_databaseLayout.file(INTERNAL_LOG_FILE));
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            // When
            NewUpgrader(upgradableDatabase, _allowMigrateConfig, pageCache).migrateIfNeeded(_databaseLayout);

            // Then
            StoreFactory factory = new StoreFactory(_databaseLayout, _allowMigrateConfig, new DefaultIdGeneratorFactory(_fileSystem), pageCache, _fileSystem, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            using (NeoStores neoStores = factory.OpenAllNeoStores())
            {
                assertThat(neoStores.MetaDataStore.UpgradeTransaction, equalTo(neoStores.MetaDataStore.LastCommittedTransaction));
                assertThat(neoStores.MetaDataStore.UpgradeTime, not(equalTo(MetaDataStore.FIELD_NOT_INITIALIZED)));

                long minuteAgo = DateTimeHelper.CurrentUnixTimeMillis() - MINUTES.toMillis(1);
                assertThat(neoStores.MetaDataStore.UpgradeTime, greaterThan(minuteAgo));
            }
        }
示例#17
0
 internal virtual bool StoreFilesUpgradable(DatabaseLayout databaseLayout, UpgradableDatabase upgradableDatabase)
 {
     try
     {
         upgradableDatabase.CheckUpgradable(databaseLayout);
         return(true);
     }
     catch (StoreUpgrader.UnableToUpgradeException)
     {
         return(false);
     }
 }
示例#18
0
        private StoreUpgrader NewUpgrader(UpgradableDatabase upgradableDatabase, PageCache pageCache, Config config)
        {
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();

            return(NewUpgrader(upgradableDatabase, pageCache, config, progressMonitor));
        }
示例#19
0
 private StoreUpgrader NewUpgrader(UpgradableDatabase upgradableDatabase, PageCache pageCache)
 {
     return(NewUpgrader(upgradableDatabase, pageCache, _allowMigrateConfig));
 }
示例#20
0
 private StoreUpgrader NewUpgrader(UpgradableDatabase upgradableDatabase, Config config, PageCache pageCache)
 {
     return(NewUpgrader(upgradableDatabase, pageCache, config));
 }