Search in sources :

Example 1 with StoreMigrator

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;
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) SchemaIndexMigrator(org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor)

Example 2 with StoreMigrator

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));
}
Also used : SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) MigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.MigrationProgressMonitor) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 3 with StoreMigrator

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);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) LegacyIndexMigrator(org.neo4j.kernel.impl.storemigration.participant.LegacyIndexMigrator) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)

Example 4 with StoreMigrator

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);
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) File(java.io.File) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) PageCache(org.neo4j.io.pagecache.PageCache) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) Test(org.junit.Test)

Example 5 with StoreMigrator

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());
}
Also used : HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) SchemaIndexMigrator(org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator) File(java.io.File) ClusterManager(org.neo4j.kernel.impl.ha.ClusterManager) Test(org.junit.Test)

Aggregations

StoreMigrator (org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)8 Test (org.junit.Test)6 File (java.io.File)5 LegacyStoreVersionCheck (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)5 PageCache (org.neo4j.io.pagecache.PageCache)4 StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)4 SilentMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor)4 SchemaIndexMigrator (org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator)4 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)3 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)3 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)2 LogService (org.neo4j.kernel.impl.logging.LogService)2 StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)2 LogProvider (org.neo4j.logging.LogProvider)2 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 EnterpriseGraphDatabaseFactory (org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory)1 DelegatingFileSystemAbstraction (org.neo4j.graphdb.mockfs.DelegatingFileSystemAbstraction)1 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)1