use of org.neo4j.kernel.impl.storemigration.participant.StoreMigrator in project neo4j by neo4j.
the class StoreUpgraderTest method newUpgrader.
private StoreUpgrader newUpgrader(UpgradableDatabase upgradableDatabase, PageCache pageCache, Config config) throws IOException {
check = new StoreVersionCheck(pageCache);
SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
NullLogService instance = NullLogService.getInstance();
StoreMigrator defaultMigrator = new StoreMigrator(fileSystem, pageCache, getTuningConfig(), instance, schemaIndexProvider);
SchemaIndexMigrator indexMigrator = new SchemaIndexMigrator(fileSystem, schemaIndexProvider, labelScanStoreProvider);
StoreUpgrader upgrader = new StoreUpgrader(upgradableDatabase, progressMonitor, config, fileSystem, pageCache, NullLogProvider.getInstance());
upgrader.addParticipant(indexMigrator);
upgrader.addParticipant(defaultMigrator);
return upgrader;
}
use of org.neo4j.kernel.impl.storemigration.participant.StoreMigrator in project neo4j by neo4j.
the class HighLimitStoreMigrationTest method migrateHighLimit3_0StoreFiles.
@Test
public void migrateHighLimit3_0StoreFiles() throws IOException {
FileSystemAbstraction fileSystem = fileSystemRule.get();
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
SchemaIndexProvider schemaIndexProvider = mock(SchemaIndexProvider.class);
StoreMigrator migrator = new StoreMigrator(fileSystem, pageCache, Config.empty(), NullLogService.getInstance(), schemaIndexProvider);
File storeDir = new File(testDirectory.graphDbDir(), "storeDir");
File migrationDir = new File(testDirectory.graphDbDir(), "migrationDir");
fileSystem.mkdir(migrationDir);
fileSystem.mkdir(storeDir);
prepareNeoStoreFile(fileSystem, storeDir, HighLimitV3_0_0.STORE_VERSION, pageCache);
MigrationProgressMonitor.Section progressMonitor = mock(MigrationProgressMonitor.Section.class);
migrator.migrate(storeDir, migrationDir, progressMonitor, HighLimitV3_0_0.STORE_VERSION, HighLimit.STORE_VERSION);
int newStoreFilesCount = fileSystem.listFiles(migrationDir).length;
assertThat("Store should be migrated and new store files should be created.", newStoreFilesCount, Matchers.greaterThanOrEqualTo(StoreType.values().length));
}
use of org.neo4j.kernel.impl.storemigration.participant.StoreMigrator in project neo4j by neo4j.
the class DatabaseMigrator method migrate.
/**
* Performs construction of {@link StoreUpgrader} and all of the necessary participants and performs store
* migration if that is required.
* @param storeDir store to migrate
*/
public void migrate(File storeDir) {
LogProvider logProvider = logService.getInternalLogProvider();
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), format);
StoreUpgrader storeUpgrader = new StoreUpgrader(upgradableDatabase, progressMonitor, config, fs, pageCache, logProvider);
StoreMigrationParticipant schemaMigrator = schemaIndexProvider.storeMigrationParticipant(fs, pageCache, labelScanStoreProvider);
LegacyIndexMigrator legacyIndexMigrator = new LegacyIndexMigrator(fs, indexProviders, logProvider);
StoreMigrator storeMigrator = new StoreMigrator(fs, pageCache, config, logService, schemaIndexProvider);
storeUpgrader.addParticipant(schemaMigrator);
storeUpgrader.addParticipant(legacyIndexMigrator);
storeUpgrader.addParticipant(storeMigrator);
storeUpgrader.migrateIfNeeded(storeDir);
}
use of org.neo4j.kernel.impl.storemigration.participant.StoreMigrator in project neo4j by neo4j.
the class StoreUpgraderInterruptionTestIT method shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMovingFiles.
@Test
public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMovingFiles() throws IOException, ConsistencyCheckIncompleteException {
File workingDirectory = directory.directory("working");
File prepareDirectory = directory.directory("prepare");
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, workingDirectory, prepareDirectory);
PageCache pageCache = pageCacheRule.getPageCache(fs);
StoreVersionCheck check = new StoreVersionCheck(pageCache);
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, check, new LegacyStoreVersionCheck(fs), Standard.LATEST_RECORD_FORMATS);
SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
LogService logService = NullLogService.getInstance();
StoreMigrator failingStoreMigrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider) {
@Override
public void moveMigratedFiles(File migrationDir, File storeDir, String versionToUpgradeFrom, String versionToMigrateTo) throws IOException {
super.moveMigratedFiles(migrationDir, storeDir, versionToUpgradeFrom, versionToMigrateTo);
throw new RuntimeException("This upgrade is failing");
}
};
assertEquals(!StandardV2_3.STORE_VERSION.equals(version), allLegacyStoreFilesHaveVersion(fs, workingDirectory, version));
try {
newUpgrader(upgradableDatabase, pageCache, progressMonitor, createIndexMigrator(), failingStoreMigrator).migrateIfNeeded(workingDirectory);
fail("Should throw exception");
} catch (RuntimeException e) {
assertEquals("This upgrade is failing", e.getMessage());
}
assertTrue(checkNeoStoreHasDefaultFormatVersion(check, workingDirectory));
assertTrue(allStoreFilesHaveNoTrailer(fs, workingDirectory));
progressMonitor = new SilentMigrationProgressMonitor();
StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
newUpgrader(upgradableDatabase, pageCache, progressMonitor, createIndexMigrator(), migrator).migrateIfNeeded(workingDirectory);
assertTrue(checkNeoStoreHasDefaultFormatVersion(check, workingDirectory));
assertTrue(allStoreFilesHaveNoTrailer(fs, workingDirectory));
pageCache.close();
// Since consistency checker is in read only mode we need to start/stop db to generate label scan store.
startStopDatabase(workingDirectory);
assertConsistentStore(workingDirectory);
}
use of org.neo4j.kernel.impl.storemigration.participant.StoreMigrator in project neo4j by neo4j.
the class StoreMigratorFrom20IT method shouldMigrateCluster.
@Test
public void shouldMigrateCluster() throws Throwable {
// Given
File legacyStoreDir = find20FormatStoreDirectory(storeDir.directory("legacy-indexes"));
// When
StoreMigrator storeMigrator = new StoreMigrator(fs, pageCache, getConfig(), NullLogService.getInstance(), schemaIndexProvider);
SchemaIndexMigrator indexMigrator = new SchemaIndexMigrator(fs, schemaIndexProvider, labelScanStoreProvider);
upgrader(indexMigrator, storeMigrator).migrateIfNeeded(legacyStoreDir);
ClusterManager.ManagedCluster cluster = buildClusterWithMasterDirIn(fs, legacyStoreDir, life, getParams());
cluster.await(allSeesAllAsAvailable());
cluster.sync();
// Then
HighlyAvailableGraphDatabase slave1 = cluster.getAnySlave();
verifySlaveContents(slave1);
verifySlaveContents(cluster.getAnySlave(slave1));
verifyDatabaseContents(cluster.getMaster());
}
Aggregations