Rebuilds the count store during migration.

Since the database may or may not reside in the upgrade directory, depending on whether the new format has different capabilities or not, we rebuild the count store using the information the store directory if we fail to open the store in the upgrade directory.

Just one out of many potential participants in a StoreUpgrader migration.

Inheritance: Org.Neo4j.Kernel.impl.storemigration.participant.AbstractStoreMigrationParticipant
コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToResumeMigrationOnRebuildingCounts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToResumeMigrationOnRebuildingCounts()
        {
            // GIVEN a legacy database
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           prepare        = _directory.directory("prepare");

            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, databaseLayout.DatabaseDirectory(), prepare);
            // and a state of the migration saying that it has done the actual migration
            LogService         logService         = NullLogService.Instance;
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fs);
            LogTailScanner     tailScanner        = GetTailScanner(databaseLayout.DatabaseDirectory());
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache, tailScanner);

            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(databaseLayout).storeVersion();
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator  migrator        = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);
            DatabaseLayout migrationLayout = _directory.databaseLayout(StoreUpgrader.MIGRATION_DIRECTORY);

            migrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // WHEN simulating resuming the migration
            progressMonitor = new SilentMigrationProgressMonitor();
            CountsMigrator countsMigrator = new CountsMigrator(_fs, pageCache, _config);

            countsMigrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            migrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            countsMigrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // THEN starting the new store should be successful
            StoreFactory storeFactory = new StoreFactory(databaseLayout, _config, new DefaultIdGeneratorFactory(_fs), pageCache, _fs, logService.InternalLogProvider, EmptyVersionContextSupplier.EMPTY);

            storeFactory.OpenAllNeoStores().close();
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToMigrateWithoutErrors() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToMigrateWithoutErrors()
        {
            // GIVEN a legacy database
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           prepare        = _directory.directory("prepare");

            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, databaseLayout.DatabaseDirectory(), prepare);

            AssertableLogProvider logProvider = new AssertableLogProvider(true);
            LogService            logService  = new SimpleLogService(logProvider, logProvider);
            PageCache             pageCache   = _pageCacheRule.getPageCache(_fs);

            LogTailScanner     tailScanner        = GetTailScanner(databaseLayout.DatabaseDirectory());
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache, tailScanner);

            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(databaseLayout).storeVersion();
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator  migrator        = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);
            CountsMigrator countsMigrator  = new CountsMigrator(_fs, pageCache, _config);
            DatabaseLayout migrationLayout = _directory.databaseLayout(StoreUpgrader.MIGRATION_DIRECTORY);

            // WHEN migrating
            migrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            countsMigrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            migrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            countsMigrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // THEN starting the new store should be successful
            StoreFactory storeFactory = new StoreFactory(databaseLayout, _config, new DefaultIdGeneratorFactory(_fs), pageCache, _fs, logService.InternalLogProvider, EmptyVersionContextSupplier.EMPTY);

            storeFactory.OpenAllNeoStores().close();
            logProvider.RawMessageMatcher().assertNotContains("ERROR");
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void detectObsoleteCountStoresToRebuildDuringMigration()
        public virtual void DetectObsoleteCountStoresToRebuildDuringMigration()
        {
            FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
            PageCache             pageCache  = mock(typeof(PageCache));
            Config         config            = Config.defaults();
            CountsMigrator storeMigrator     = new CountsMigrator(fileSystem, pageCache, config);
            ISet <string>  actualVersions    = new HashSet <string>();
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <string> expectedVersions = java.util.org.neo4j.kernel.impl.store.format.StoreVersion.values().Select(StoreVersion::versionString).collect(Collectors.toSet());

            assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.STANDARD_V2_3.versionString()));
            actualVersions.Add(StoreVersion.STANDARD_V2_3.versionString());
            assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.STANDARD_V3_0.versionString()));
            actualVersions.Add(StoreVersion.STANDARD_V3_0.versionString());
            assertFalse(CountsMigrator.CountStoreRebuildRequired(StoreVersion.STANDARD_V3_2.versionString()));
            actualVersions.Add(StoreVersion.STANDARD_V3_2.versionString());
            assertFalse(CountsMigrator.CountStoreRebuildRequired(StoreVersion.STANDARD_V3_4.versionString()));
            actualVersions.Add(StoreVersion.STANDARD_V3_4.versionString());

            assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_0_0.versionString()));
            actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_0_0.versionString());
            assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_0_6.versionString()));
            actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_0_6.versionString());
            assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_1_0.versionString()));
            actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_1_0.versionString());
            assertFalse(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_2_0.versionString()));
            actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_2_0.versionString());
            assertFalse(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_4_0.versionString()));
            actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_4_0.versionString());

            assertEquals(expectedVersions, actualVersions);
        }
コード例 #4
0
ファイル: CountsMigratorTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAccidentallyDeleteStoreFilesIfNoMigrationWasRequired() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotAccidentallyDeleteStoreFilesIfNoMigrationWasRequired()
        {
            // given
            CountsMigrator migrator         = new CountsMigrator(_fs, null, Config.defaults());
            DatabaseLayout sourceLayout     = _directory.databaseLayout();
            File           countsStoreFileA = sourceLayout.CountStoreA();
            File           countsStoreFileB = sourceLayout.CountStoreB();

            _fs.create(countsStoreFileA);
            _fs.create(countsStoreFileB);
            DatabaseLayout migrationLayout      = _directory.databaseLayout("migration");
            string         versionToMigrateFrom = StoreVersion.STANDARD_V3_2.versionString();
            string         versionToMigrateTo   = StoreVersion.STANDARD_V3_4.versionString();

            migrator.Migrate(sourceLayout, migrationLayout, SilentProgressReporter.INSTANCE, versionToMigrateFrom, versionToMigrateTo);
            assertEquals("Invalid test assumption: There should not have been migration for those versions", 0, migrationLayout.ListDatabaseFiles((dir, name) => true).Length);

            // when
            migrator.MoveMigratedFiles(migrationLayout, sourceLayout, versionToMigrateFrom, versionToMigrateTo);

            // then
            assertTrue(_fs.fileExists(countsStoreFileA));
            assertTrue(_fs.fileExists(countsStoreFileB));
        }