Search in sources :

Example 16 with LegacyStoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method upgradeShouldNotLeaveLeftoverAndMigrationDirs.

@Test
public void upgradeShouldNotLeaveLeftoverAndMigrationDirs() throws Exception {
    // Given
    fileSystem.deleteFile(new File(dbDirectory, StoreLogService.INTERNAL_LOG_NAME));
    PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
    // When
    newUpgrader(upgradableDatabase, allowMigrateConfig, pageCache).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) 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 17 with LegacyStoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method upgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId.

@Test
public void upgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId() throws Exception {
    // Given
    fileSystem.deleteFile(new File(dbDirectory, StoreLogService.INTERNAL_LOG_NAME));
    PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
    // When
    newUpgrader(upgradableDatabase, allowMigrateConfig, pageCache).migrateIfNeeded(dbDirectory);
    // Then
    StoreFactory factory = new StoreFactory(dbDirectory, pageCache, fileSystem, NullLogProvider.getInstance());
    try (NeoStores neoStores = factory.openAllNeoStores()) {
        assertThat(neoStores.getMetaDataStore().getUpgradeTransaction(), equalTo(neoStores.getMetaDataStore().getLastCommittedTransaction()));
        assertThat(neoStores.getMetaDataStore().getUpgradeTime(), not(equalTo(MetaDataStore.FIELD_NOT_INITIALIZED)));
        long minuteAgo = System.currentTimeMillis() - MINUTES.toMillis(1);
        assertThat(neoStores.getMetaDataStore().getUpgradeTime(), greaterThan(minuteAgo));
    }
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) NeoStores(org.neo4j.kernel.impl.store.NeoStores) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) MigrationTestUtils.truncateFile(org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 18 with LegacyStoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck in project neo4j by neo4j.

the class StoreMigratorIT method shouldBeAbleToResumeMigrationOnMoving.

@Test
public void shouldBeAbleToResumeMigrationOnMoving() throws Exception {
    // GIVEN a legacy database
    File storeDirectory = directory.graphDbDir();
    File prepare = directory.directory("prepare");
    MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, storeDirectory, prepare);
    // and a state of the migration saying that it has done the actual migration
    LogService logService = NullLogService.getInstance();
    PageCache pageCache = pageCacheRule.getPageCache(fs);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), selectFormat());
    String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(storeDirectory).storeVersion();
    SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
    StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
    File migrationDir = new File(storeDirectory, StoreUpgrader.MIGRATION_DIRECTORY);
    fs.mkdirs(migrationDir);
    migrator.migrate(storeDirectory, migrationDir, progressMonitor.startSection("section"), versionToMigrateFrom, upgradableDatabase.currentVersion());
    // WHEN simulating resuming the migration
    progressMonitor = new SilentMigrationProgressMonitor();
    migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
    migrator.moveMigratedFiles(migrationDir, storeDirectory, versionToMigrateFrom, upgradableDatabase.currentVersion());
    // THEN starting the new store should be successful
    StoreFactory storeFactory = new StoreFactory(storeDirectory, pageCache, fs, logService.getInternalLogProvider());
    storeFactory.openAllNeoStores().close();
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) File(java.io.File) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 19 with LegacyStoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck in project neo4j by neo4j.

the class StoreMigratorIT method shouldComputeTheLastTxLogPositionCorrectly.

@Test
public void shouldComputeTheLastTxLogPositionCorrectly() throws Throwable {
    // GIVEN a legacy database
    File storeDirectory = directory.graphDbDir();
    File prepare = directory.directory("prepare");
    MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, storeDirectory, prepare);
    // and a state of the migration saying that it has done the actual migration
    LogService logService = NullLogService.getInstance();
    PageCache pageCache = pageCacheRule.getPageCache(fs);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), selectFormat());
    String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(storeDirectory).storeVersion();
    SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
    StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
    File migrationDir = new File(storeDirectory, StoreUpgrader.MIGRATION_DIRECTORY);
    fs.mkdirs(migrationDir);
    // WHEN migrating
    migrator.migrate(storeDirectory, migrationDir, progressMonitor.startSection("section"), versionToMigrateFrom, upgradableDatabase.currentVersion());
    // THEN it should compute the correct last tx log position
    assertEquals(expectedLogPosition, migrator.readLastTxLogPosition(migrationDir));
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) File(java.io.File) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 20 with LegacyStoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck in project neo4j by neo4j.

the class StoreMigratorIT method shouldBeAbleToResumeMigrationOnRebuildingCounts.

@Test
public void shouldBeAbleToResumeMigrationOnRebuildingCounts() throws Exception {
    // GIVEN a legacy database
    File storeDirectory = directory.graphDbDir();
    File prepare = directory.directory("prepare");
    MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, storeDirectory, prepare);
    // and a state of the migration saying that it has done the actual migration
    LogService logService = NullLogService.getInstance();
    PageCache pageCache = pageCacheRule.getPageCache(fs);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), selectFormat());
    String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(storeDirectory).storeVersion();
    SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
    StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
    File migrationDir = new File(storeDirectory, StoreUpgrader.MIGRATION_DIRECTORY);
    fs.mkdirs(migrationDir);
    migrator.migrate(storeDirectory, migrationDir, progressMonitor.startSection("section"), versionToMigrateFrom, upgradableDatabase.currentVersion());
    migrator.moveMigratedFiles(migrationDir, storeDirectory, versionToMigrateFrom, upgradableDatabase.currentVersion());
    // WHEN simulating resuming the migration
    progressMonitor = new SilentMigrationProgressMonitor();
    migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
    migrator.rebuildCounts(storeDirectory, versionToMigrateFrom, upgradableDatabase.currentVersion());
    // THEN starting the new store should be successful
    StoreFactory storeFactory = new StoreFactory(storeDirectory, pageCache, fs, logService.getInternalLogProvider());
    storeFactory.openAllNeoStores().close();
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) File(java.io.File) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Aggregations

LegacyStoreVersionCheck (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)21 File (java.io.File)17 PageCache (org.neo4j.io.pagecache.PageCache)17 StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)17 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)17 Test (org.junit.Test)16 SilentMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor)8 MigrationTestUtils.truncateFile (org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile)7 LogService (org.neo4j.kernel.impl.logging.LogService)6 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)6 StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)6 StoreMigrator (org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)4 IOException (java.io.IOException)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)3 UnableToUpgradeException (org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException)3 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)2 FilenameFilter (java.io.FilenameFilter)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1