Search in sources :

Example 1 with StoreUpgrader

use of org.neo4j.kernel.impl.storemigration.StoreUpgrader in project neo4j by neo4j.

the class StoreMigratorFrom20IT method upgrader.

private StoreUpgrader upgrader(SchemaIndexMigrator indexMigrator, StoreMigrator storeMigrator) {
    Config config = getConfig().augment(stringMap(GraphDatabaseSettings.allow_store_upgrade.name(), "true"));
    StoreUpgrader upgrader = new StoreUpgrader(upgradableDatabase, monitor, config, fs, pageCache, NullLogProvider.getInstance());
    upgrader.addParticipant(indexMigrator);
    upgrader.addParticipant(storeMigrator);
    return upgrader;
}
Also used : Config(org.neo4j.kernel.configuration.Config) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader)

Example 2 with StoreUpgrader

use of org.neo4j.kernel.impl.storemigration.StoreUpgrader in project neo4j by neo4j.

the class StoreUpgraderInterruptionTestIT method newUpgrader.

private StoreUpgrader newUpgrader(UpgradableDatabase upgradableDatabase, PageCache pageCache, MigrationProgressMonitor progressMonitor, SchemaIndexMigrator indexMigrator, StoreMigrator migrator) {
    Config allowUpgrade = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.allow_store_upgrade.name(), "true"));
    StoreUpgrader upgrader = new StoreUpgrader(upgradableDatabase, progressMonitor, allowUpgrade, fs, pageCache, NullLogProvider.getInstance());
    upgrader.addParticipant(indexMigrator);
    upgrader.addParticipant(migrator);
    return upgrader;
}
Also used : Config(org.neo4j.kernel.configuration.Config) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader)

Example 3 with StoreUpgrader

use of org.neo4j.kernel.impl.storemigration.StoreUpgrader 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 4 with StoreUpgrader

use of org.neo4j.kernel.impl.storemigration.StoreUpgrader in project neo4j by neo4j.

the class StoreUpgraderTest method upgraderShouldCleanupLegacyLeftoverAndMigrationDirs.

@Test
public void upgraderShouldCleanupLegacyLeftoverAndMigrationDirs() throws Exception {
    // Given
    fileSystem.deleteFile(new File(dbDirectory, StoreLogService.INTERNAL_LOG_NAME));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_DIRECTORY));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_1"));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_2"));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_42"));
    PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
    // When
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
    StoreUpgrader storeUpgrader = newUpgrader(upgradableDatabase, pageCache);
    storeUpgrader.migrateIfNeeded(dbDirectory);
    // Then
    assertThat(migrationHelperDirs(), is(emptyCollectionOf(File.class)));
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) MigrationTestUtils.truncateFile(org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 5 with StoreUpgrader

use of org.neo4j.kernel.impl.storemigration.StoreUpgrader in project neo4j by neo4j.

the class StoreUpgraderTest method shouldContinueMovingFilesIfUpgradeCancelledWhileMoving.

@Test
public void shouldContinueMovingFilesIfUpgradeCancelledWhileMoving() throws Exception {
    PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
    String versionToMigrateTo = upgradableDatabase.currentVersion();
    String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(dbDirectory).storeVersion();
    // GIVEN
    {
        StoreUpgrader upgrader = newUpgrader(upgradableDatabase, allowMigrateConfig, pageCache);
        String failureMessage = "Just failing";
        upgrader.addParticipant(participantThatWillFailWhenMoving(failureMessage));
        // WHEN
        try {
            upgrader.migrateIfNeeded(dbDirectory);
            fail("should have thrown");
        } catch (UnableToUpgradeException e) {
            // THEN
            assertTrue(e.getCause() instanceof IOException);
            assertEquals(failureMessage, e.getCause().getMessage());
        }
    }
    // AND WHEN
    {
        StoreUpgrader upgrader = newUpgrader(upgradableDatabase, pageCache);
        StoreMigrationParticipant observingParticipant = Mockito.mock(StoreMigrationParticipant.class);
        upgrader.addParticipant(observingParticipant);
        upgrader.migrateIfNeeded(dbDirectory);
        // THEN
        verify(observingParticipant, Mockito.times(0)).migrate(any(File.class), any(File.class), any(MigrationProgressMonitor.Section.class), eq(versionToMigrateFrom), eq(versionToMigrateTo));
        verify(observingParticipant, Mockito.times(1)).moveMigratedFiles(any(File.class), any(File.class), eq(versionToMigrateFrom), eq(versionToMigrateTo));
        verify(observingParticipant, Mockito.times(1)).cleanup(any(File.class));
    }
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UnableToUpgradeException(org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) MigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.MigrationProgressMonitor) StoreMigrationParticipant(org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant) AbstractStoreMigrationParticipant(org.neo4j.kernel.impl.storemigration.participant.AbstractStoreMigrationParticipant) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) Matchers.containsString(org.hamcrest.Matchers.containsString) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) IOException(java.io.IOException) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Aggregations

StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)6 StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)4 LegacyStoreVersionCheck (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)4 Test (org.junit.Test)3 PageCache (org.neo4j.io.pagecache.PageCache)3 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)3 SilentMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor)3 File (java.io.File)2 IOException (java.io.IOException)2 Config (org.neo4j.kernel.configuration.Config)2 MigrationTestUtils.truncateFile (org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile)2 StoreMigrator (org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)2 FilenameFilter (java.io.FilenameFilter)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 DelegatingFileSystemAbstraction (org.neo4j.graphdb.mockfs.DelegatingFileSystemAbstraction)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)1 StoreMigrationParticipant (org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant)1 UnableToUpgradeException (org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException)1 MigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.MigrationProgressMonitor)1