private static void cleanup( Iterable<StoreMigrationParticipant> participants, DatabaseLayout migrationStructure ) { try { for ( StoreMigrationParticipant participant : participants ) { participant.cleanup( migrationStructure ); } } catch ( IOException e ) { throw new UnableToUpgradeException( "Failure cleaning up after migration", e ); } }
public UpgradeNotAllowedByConfigurationException() { super( baseMessage() ); }
public UpgradeDisallowedStartupException( UpgradeNotAllowedException cause ) { super( cause.getMessage(), cause ); }
private static UpgradableDatabase getUpgradableDatabase( PageCache pageCache, LogTailScanner tailScanner ) { return new UpgradableDatabase( new StoreVersionCheck( pageCache ), selectFormat(), tailScanner ); }
@Test public void shouldReportShortFileDoesNotHaveSpecifiedVersion() throws IOException { // given File shortFile = fileContaining( fileSystemRule.get(), "nothing interesting" ); StoreVersionCheck storeVersionCheck = new StoreVersionCheck( pageCacheRule.getPageCache( fileSystemRule.get() ) ); // when StoreVersionCheck.Result result = storeVersionCheck.hasVersion( shortFile, "version" ); // then assertFalse( result.outcome.isSuccessful() ); assertEquals( StoreVersionCheck.Result.Outcome.storeVersionNotFound, result.outcome ); assertNull( result.actualVersion ); }
private UpgradableDatabase getUpgradableDatabase( PageCache pageCache ) throws IOException { VersionAwareLogEntryReader<ReadableClosablePositionAwareChannel> entryReader = new VersionAwareLogEntryReader<>(); LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder( databaseLayout.databaseDirectory(), fileSystem ) .withLogEntryReader( entryReader ).build(); LogTailScanner tailScanner = new LogTailScanner( logFiles, entryReader, new Monitors() ); return new UpgradableDatabase( new StoreVersionCheck( pageCache ), getRecordFormats(), tailScanner ); }
private void migrateToIsolatedDirectory( DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, String versionToMigrateFrom ) { try { for ( StoreMigrationParticipant participant : participants ) { ProgressReporter progressReporter = progressMonitor.startSection( participant.getName() ); participant.migrate( directoryLayout, migrationLayout, progressReporter, versionToMigrateFrom, upgradableDatabase.currentVersion() ); progressReporter.completed(); } } catch ( IOException | UncheckedIOException e ) { throw new UnableToUpgradeException( "Failure doing migration", e ); } }
private StoreUpgrader newUpgrader( UpgradableDatabase upgradableDatabase, PageCache pageCache, Config config ) { SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor(); return newUpgrader( upgradableDatabase, pageCache, config, progressMonitor ); }
public static boolean checkNeoStoreHasDefaultFormatVersion( StoreVersionCheck check, DatabaseLayout databaseLayout ) { File metadataStore = databaseLayout.metadataStore(); return check.hasVersion( metadataStore, RecordFormatSelector.defaultFormat().storeVersion() ).outcome.isSuccessful(); }
private static void moveMigratedFilesToStoreDirectory( Iterable<StoreMigrationParticipant> participants, DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToMigrateFrom, String versionToMigrateTo ) { try { for ( StoreMigrationParticipant participant : participants ) { participant.moveMigratedFiles( migrationLayout, directoryLayout, versionToMigrateFrom, versionToMigrateTo ); } } catch ( IOException e ) { throw new UnableToUpgradeException( "Unable to move migrated files into place", e ); } }
protected void prepareSampleDatabase( String version, FileSystemAbstraction fileSystem, DatabaseLayout databaseLayout, File databaseDirectory ) throws IOException { MigrationTestUtils.prepareSampleLegacyDatabase( version, fileSystem, databaseLayout.databaseDirectory(), databaseDirectory ); }
@Test public void notParticipatingParticipantsAreNotPartOfMigration() throws IOException { PageCache pageCache = pageCacheRule.getPageCache( fileSystem ); UpgradableDatabase upgradableDatabase = getUpgradableDatabase( pageCache ); StoreUpgrader storeUpgrader = newUpgrader( upgradableDatabase, pageCache ); assertThat( storeUpgrader.getParticipants(), hasSize( 3 ) ); }
public static MigrationStatus readMigrationStatus( FileSystemAbstraction fs, File stateFile ) { Pair<String,String> data = readFromFile( fs, stateFile, null ); if ( data == null ) { return null; } return MigrationStatus.valueOf( data.first() ); }
private StoreUpgrader newUpgrader( UpgradableDatabase upgradableDatabase, Config config, PageCache pageCache ) { return newUpgrader( upgradableDatabase, pageCache, config ); }
public String maybeReadInfo( FileSystemAbstraction fs, File stateFile, String currentInfo ) { if ( currentInfo != null ) { return currentInfo; } Pair<String,String> data = readFromFile( fs, stateFile, this ); return data == null ? null : data.other(); }
private Config getTuningConfig() { return Config.defaults( GraphDatabaseSettings.record_format, getRecordFormatsName() ); }
private void cleanMigrationDirectory( File migrationDirectory ) { try { if ( fileSystem.fileExists( migrationDirectory ) ) { fileSystem.deleteRecursively( migrationDirectory ); } } catch ( IOException | UncheckedIOException e ) { throw new UnableToUpgradeException( "Failure deleting upgrade directory " + migrationDirectory, e ); } fileSystem.mkdir( migrationDirectory ); }
public UpgradeNotAllowedByConfigurationException( String msg ) { super( String.format( "%s Detailed description: %s", baseMessage() , msg) ); }
private StoreUpgrader newUpgrader( UpgradableDatabase upgradableDatabase, PageCache pageCache ) { return newUpgrader( upgradableDatabase, pageCache, allowMigrateConfig ); }