Beispiel #1
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));
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
Beispiel #4
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)));
            }
        }
Beispiel #5
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))));
        }