private void migrateStore( DatabaseLayout dbDirectoryLayout, DatabaseLayout migrationLayout, File migrationStateFile ) { // One or more participants would like to do migration progressMonitor.started( participants.size() ); MigrationStatus migrationStatus = MigrationStatus.readMigrationStatus( fileSystem, migrationStateFile ); String versionToMigrateFrom = null; // We don't need to migrate if we're at the phase where we have migrated successfully // and it's just a matter of moving over the files to the storeDir. if ( MigrationStatus.migrating.isNeededFor( migrationStatus ) ) { versionToMigrateFrom = upgradableDatabase.checkUpgradable( dbDirectoryLayout ).storeVersion(); cleanMigrationDirectory( migrationLayout.databaseDirectory() ); MigrationStatus.migrating.setMigrationStatus( fileSystem, migrationStateFile, versionToMigrateFrom ); migrateToIsolatedDirectory( dbDirectoryLayout, migrationLayout, versionToMigrateFrom ); MigrationStatus.moving.setMigrationStatus( fileSystem, migrationStateFile, versionToMigrateFrom ); } if ( MigrationStatus.moving.isNeededFor( migrationStatus ) ) { versionToMigrateFrom = MigrationStatus.moving.maybeReadInfo( fileSystem, migrationStateFile, versionToMigrateFrom ); moveMigratedFilesToStoreDirectory( participants, migrationLayout, dbDirectoryLayout, versionToMigrateFrom, upgradableDatabase.currentVersion() ); } cleanup( participants, migrationLayout ); progressMonitor.completed(); }
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 void migrateStore( DatabaseLayout dbDirectoryLayout, DatabaseLayout migrationLayout, File migrationStateFile ) { // One or more participants would like to do migration progressMonitor.started( participants.size() ); MigrationStatus migrationStatus = MigrationStatus.readMigrationStatus( fileSystem, migrationStateFile ); String versionToMigrateFrom = null; // We don't need to migrate if we're at the phase where we have migrated successfully // and it's just a matter of moving over the files to the storeDir. if ( MigrationStatus.migrating.isNeededFor( migrationStatus ) ) { versionToMigrateFrom = upgradableDatabase.checkUpgradable( dbDirectoryLayout ).storeVersion(); cleanMigrationDirectory( migrationLayout.databaseDirectory() ); MigrationStatus.migrating.setMigrationStatus( fileSystem, migrationStateFile, versionToMigrateFrom ); migrateToIsolatedDirectory( dbDirectoryLayout, migrationLayout, versionToMigrateFrom ); MigrationStatus.moving.setMigrationStatus( fileSystem, migrationStateFile, versionToMigrateFrom ); } if ( MigrationStatus.moving.isNeededFor( migrationStatus ) ) { versionToMigrateFrom = MigrationStatus.moving.maybeReadInfo( fileSystem, migrationStateFile, versionToMigrateFrom ); moveMigratedFilesToStoreDirectory( participants, migrationLayout, dbDirectoryLayout, versionToMigrateFrom, upgradableDatabase.currentVersion() ); } cleanup( participants, migrationLayout ); progressMonitor.completed(); }
/** * Builds the counts store. Requires that {@link #importNodes()} and {@link #importRelationships()} has run. */ public void buildCountsStore() { // Count nodes per label and labels per node try ( CountsAccessor.Updater countsUpdater = neoStore.getCountsStore().reset( neoStore.getLastCommittedTransactionId() ) ) { MigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor(); nodeLabelsCache = new NodeLabelsCache( numberArrayFactory, neoStore.getLabelRepository().getHighId() ); MemoryUsageStatsProvider memoryUsageStats = new MemoryUsageStatsProvider( neoStore, nodeLabelsCache ); executeStage( new NodeCountsAndLabelIndexBuildStage( config, nodeLabelsCache, neoStore.getNodeStore(), neoStore.getLabelRepository().getHighId(), countsUpdater, progressMonitor.startSection( "Nodes" ), neoStore.getLabelScanStore(), memoryUsageStats ) ); // Count label-[type]->label executeStage( new RelationshipCountsStage( config, nodeLabelsCache, neoStore.getRelationshipStore(), neoStore.getLabelRepository().getHighId(), neoStore.getRelationshipTypeRepository().getHighId(), countsUpdater, numberArrayFactory, progressMonitor.startSection( "Relationships" ) ) ); } }
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 ); } }
/** * Builds the counts store. Requires that {@link #importNodes()} and {@link #importRelationships()} has run. */ public void buildCountsStore() { // Count nodes per label and labels per node try ( CountsAccessor.Updater countsUpdater = neoStore.getCountsStore().reset( neoStore.getLastCommittedTransactionId() ) ) { MigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor(); nodeLabelsCache = new NodeLabelsCache( numberArrayFactory, neoStore.getLabelRepository().getHighId() ); MemoryUsageStatsProvider memoryUsageStats = new MemoryUsageStatsProvider( neoStore, nodeLabelsCache ); executeStage( new NodeCountsAndLabelIndexBuildStage( config, nodeLabelsCache, neoStore.getNodeStore(), neoStore.getLabelRepository().getHighId(), countsUpdater, progressMonitor.startSection( "Nodes" ), neoStore.getLabelScanStore(), memoryUsageStats ) ); // Count label-[type]->label executeStage( new RelationshipCountsStage( config, nodeLabelsCache, neoStore.getRelationshipStore(), neoStore.getLabelRepository().getHighId(), neoStore.getRelationshipTypeRepository().getHighId(), countsUpdater, numberArrayFactory, progressMonitor.startSection( "Relationships" ) ) ); } }