@Override public StoreMigrationParticipant storeMigrationParticipant( final FileSystemAbstraction fs, PageCache pageCache ) { return new SchemaIndexMigrator( fs, this ); }
@Override public void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToUpgradeFrom, String versionToMigrateTo ) throws IOException { if ( deleteObsoleteIndexes ) { deleteIndexes( schemaIndexDirectory ); } }
@Override public void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToUpgradeFrom, String versionToUpgradeTo ) throws IOException { if ( migrated ) { // Delete any current count files in the store directory. fileOperation( DELETE, fileSystem, directoryLayout, directoryLayout, COUNTS_STORE_FILES, true, null ); // Move the migrated ones into the store directory fileOperation( MOVE, fileSystem, migrationLayout, directoryLayout, COUNTS_STORE_FILES, true, // allow to skip non existent source files ExistingTargetStrategy.OVERWRITE ); // We do not need to move files with the page cache, as the count files always reside on the normal file system. } }
@Test public void cleanupMigrationDirectory() throws IOException { when( fs.fileExists( migratedIndexStore ) ).thenReturn( true ); ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, true ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); indexMigrator.cleanup( migrationLayout ); verify( fs ).deleteRecursively( migratedIndexStore ); }
@Test public void transferMigratedIndexesToStoreDirectory() throws IOException { ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, true ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); reset( fs ); indexMigrator.moveMigratedFiles( migrationLayout, storeLayout, "any", "any" ); verify( fs ).deleteRecursively( originalIndexStore ); verify( fs ).moveToDirectory( migratedIndexStore, storeLayout.databaseDirectory() ); }
@Test public void skipMigrationIfNativeIndexExist() throws Exception { ByteBuffer sourceBuffer = writeFile( nativeLabelIndex, new byte[]{1, 2, 3} ); indexMigrator.migrate( databaseLayout, migrationLayout, progressReporter, StandardV3_2.STORE_VERSION, StandardV3_2.STORE_VERSION ); indexMigrator.moveMigratedFiles( migrationLayout, databaseLayout, StandardV3_2.STORE_VERSION, StandardV3_2.STORE_VERSION ); ByteBuffer resultBuffer = readFileContent( nativeLabelIndex, 3 ); assertEquals( sourceBuffer, resultBuffer ); assertTrue( fileSystem.fileExists( luceneLabelScanStore ) ); }
@Override public void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToUpgradeFrom, String versionToMigrateTo ) throws IOException { if ( nativeLabelScanStoreMigrated ) { File nativeLabelIndex = migrationLayout.labelScanStore(); moveNativeIndexFile( directoryLayout, nativeLabelIndex ); deleteLuceneLabelIndex( getLuceneStoreDirectory( directoryLayout ) ); } }
@Override public void migrate( DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressReporter, String versionToMigrateFrom, String versionToMigrateTo ) throws IOException { super.migrate( directoryLayout, migrationLayout, progressReporter, versionToMigrateFrom, versionToMigrateTo ); throw new RuntimeException( "This upgrade is failing" ); } };
@Test public void transferOriginalDataToMigrationDirectory() throws IOException { ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, true ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); verify( fs ).copyRecursively( originalIndexStore, migratedIndexStore ); }
@Test( expected = InvalidIdGeneratorException.class ) public void failMigrationWhenNodeIdFileIsBroken() throws Exception { prepareEmpty23Database(); File nodeIdFile = databaseLayout.idNodeStore(); writeFile( nodeIdFile, new byte[]{1, 2, 3} ); indexMigrator.migrate( databaseLayout, migrationLayout, progressReporter, StandardV3_2.STORE_VERSION, StandardV3_2.STORE_VERSION ); }
@Test public void luceneLabelIndexRemovedAfterSuccessfulMigration() throws IOException { prepareEmpty23Database(); indexMigrator.migrate( databaseLayout, migrationLayout, progressReporter, StandardV2_3.STORE_VERSION, StandardV3_2.STORE_VERSION ); indexMigrator.moveMigratedFiles( migrationLayout, databaseLayout, StandardV2_3.STORE_VERSION, StandardV3_2.STORE_VERSION ); assertFalse( fileSystem.fileExists( luceneLabelScanStore ) ); }
TransactionId readLastTxInformation( DatabaseLayout migrationStructure ) throws IOException { long[] counters = readTxLogCounters( fileSystem, lastTxInformationFile( migrationStructure ), 3 ); return new TransactionId( counters[0], counters[1], counters[2] ); }
void writeLastTxInformation( DatabaseLayout migrationStructure, TransactionId txInfo ) throws IOException { writeTxLogCounters( fileSystem, lastTxInformationFile( migrationStructure ), txInfo.transactionId(), txInfo.checksum(), txInfo.commitTimestamp() ); }
@Override public void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToUpgradeFrom, String versionToMigrateTo ) throws IOException { super.moveMigratedFiles( migrationLayout, directoryLayout, versionToUpgradeFrom, versionToMigrateTo ); throw new RuntimeException( "This upgrade is failing" ); } };
@Override LuceneExplicitIndexUpgrader createLuceneExplicitIndexUpgrader( Path indexRootPath, ProgressReporter progressReporter ) { return new HumbleExplicitIndexUpgrader( indexRootPath, successfulMigration ); } }
BatchImporterProgressMonitor( long highNodeId, long highRelationshipId, org.neo4j.unsafe.impl.batchimport.Configuration configuration, ProgressReporter progressReporter ) { super( highNodeId, highRelationshipId, configuration ); this.progressReporter = progressReporter; this.progressReporter.start( total() ); }
LuceneExplicitIndexUpgrader createLuceneExplicitIndexUpgrader( Path indexRootPath, ProgressReporter progressMonitor ) { return new LuceneExplicitIndexUpgrader( indexRootPath, progressMonitor( progressMonitor ) ); }
private ByteBuffer writeFile( File file, byte[] content ) throws IOException { ByteBuffer sourceBuffer = ByteBuffer.wrap( content ); storeFileContent( file, sourceBuffer ); sourceBuffer.flip(); return sourceBuffer; }
@Override public StoreMigrationParticipant storeMigrationParticipant( final FileSystemAbstraction fs, PageCache pageCache ) { return new SchemaIndexMigrator( fs, this ); }
private SchemaIndexMigrator createIndexMigrator() { return new SchemaIndexMigrator( fs, IndexProvider.EMPTY ); }