Search in sources :

Example 1 with SchemaIndexMigrator

use of org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator 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 SchemaIndexMigrator

use of org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator 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)

Example 3 with SchemaIndexMigrator

use of org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator in project neo4j by neo4j.

the class StoreMigratorFrom20IT method shouldMigrate.

@Test
public void shouldMigrate() throws IOException, ConsistencyCheckIncompleteException {
    // WHEN
    StoreMigrator storeMigrator = new StoreMigrator(fs, pageCache, getConfig(), NullLogService.getInstance(), schemaIndexProvider);
    SchemaIndexMigrator indexMigrator = new SchemaIndexMigrator(fs, schemaIndexProvider, labelScanStoreProvider);
    upgrader(indexMigrator, storeMigrator).migrateIfNeeded(find20FormatStoreDirectory(storeDir.directory()));
    // THEN
    assertEquals(2, monitor.progresses().size());
    assertTrue(monitor.isStarted());
    assertTrue(monitor.isFinished());
    GraphDatabaseService database = new EnterpriseGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir.absolutePath()).newGraphDatabase();
    try {
        verifyDatabaseContents(database);
    } finally {
        // CLEANUP
        database.shutdown();
    }
    LogProvider logProvider = NullLogProvider.getInstance();
    StoreFactory storeFactory = new StoreFactory(storeDir.directory(), pageCache, fs, logProvider);
    try (NeoStores neoStores = storeFactory.openAllNeoStores(true)) {
        verifyNeoStore(neoStores);
    }
    assertConsistentStore(storeDir.directory());
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) NullLogProvider(org.neo4j.logging.NullLogProvider) LogProvider(org.neo4j.logging.LogProvider) EnterpriseGraphDatabaseFactory(org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory) NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) SchemaIndexMigrator(org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) Test(org.junit.Test)

Example 4 with SchemaIndexMigrator

use of org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator in project neo4j by neo4j.

the class StoreUpgraderInterruptionTestIT method shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration.

@Test
public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration() throws IOException, ConsistencyCheckIncompleteException {
    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 migrate(File sourceStoreDir, File targetStoreDir, MigrationProgressMonitor.Section progressMonitor, String versionToMigrateFrom, String versionToMigrateTo) throws IOException {
            super.migrate(sourceStoreDir, targetStoreDir, progressMonitor, versionToMigrateFrom, 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());
    }
    assertEquals(!StandardV2_3.STORE_VERSION.equals(version), allLegacyStoreFilesHaveVersion(fs, workingDirectory, version));
    progressMonitor = new SilentMigrationProgressMonitor();
    StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
    SchemaIndexMigrator indexMigrator = createIndexMigrator();
    newUpgrader(upgradableDatabase, pageCache, progressMonitor, indexMigrator, migrator).migrateIfNeeded(workingDirectory);
    assertTrue(checkNeoStoreHasDefaultFormatVersion(check, workingDirectory));
    assertTrue(allStoreFilesHaveNoTrailer(fs, workingDirectory));
    // 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) SchemaIndexMigrator(org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) Test(org.junit.Test)

Aggregations

SchemaIndexMigrator (org.neo4j.kernel.impl.storemigration.participant.SchemaIndexMigrator)4 StoreMigrator (org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)4 Test (org.junit.Test)3 File (java.io.File)2 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)2 StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)2 LegacyStoreVersionCheck (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)2 SilentMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor)2 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 EnterpriseGraphDatabaseFactory (org.neo4j.graphdb.factory.EnterpriseGraphDatabaseFactory)1 PageCache (org.neo4j.io.pagecache.PageCache)1 HighlyAvailableGraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)1 ClusterManager (org.neo4j.kernel.impl.ha.ClusterManager)1 LogService (org.neo4j.kernel.impl.logging.LogService)1 NeoStores (org.neo4j.kernel.impl.store.NeoStores)1 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)1 StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)1 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)1 LogProvider (org.neo4j.logging.LogProvider)1 NullLogProvider (org.neo4j.logging.NullLogProvider)1