/// <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); }
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); }
//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))); } }