Search in sources :

Example 1 with StoreMigrationParticipant

use of org.neo4j.storageengine.migration.StoreMigrationParticipant in project neo4j by neo4j.

the class StoreUpgraderInterruptionTestIT method newUpgrader.

private StoreUpgrader newUpgrader(StoreVersionCheck versionCheck, MigrationProgressMonitor progressMonitor, StoreMigrationParticipant... participants) {
    Config config = Config.defaults(allow_upgrade, true);
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependencies(new Monitors());
    RecordStorageEngineFactory storageEngineFactory = new RecordStorageEngineFactory();
    var databaseHealth = new DatabaseHealth(PanicEventGenerator.NO_OP, NullLog.getInstance());
    LogsUpgrader logsUpgrader = new LogsUpgrader(fs, storageEngineFactory, workingDatabaseLayout, pageCache, legacyTransactionLogsLocator, config, dependencies, NULL, INSTANCE, databaseHealth, false);
    StoreUpgrader upgrader = new StoreUpgrader(versionCheck, progressMonitor, config, fs, NullLogProvider.getInstance(), logsUpgrader, NULL);
    for (StoreMigrationParticipant participant : participants) {
        upgrader.addParticipant(participant);
    }
    return upgrader;
}
Also used : DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) RecordStorageEngineFactory(org.neo4j.internal.recordstorage.RecordStorageEngineFactory) LogsUpgrader(org.neo4j.kernel.impl.storemigration.LogsUpgrader) Config(org.neo4j.configuration.Config) StoreMigrationParticipant(org.neo4j.storageengine.migration.StoreMigrationParticipant) Monitors(org.neo4j.monitoring.Monitors) Dependencies(org.neo4j.collection.Dependencies) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader)

Example 2 with StoreMigrationParticipant

use of org.neo4j.storageengine.migration.StoreMigrationParticipant in project neo4j by neo4j.

the class StoreUpgraderTest method shouldContinueMovingFilesIfUpgradeCancelledWhileMoving.

@ParameterizedTest
@MethodSource("versions")
void shouldContinueMovingFilesIfUpgradeCancelledWhileMoving(RecordFormats formats) throws Exception {
    init(formats);
    StoreVersionCheck check = getVersionCheck(pageCache);
    String versionToMigrateTo = check.configuredVersion();
    StoreVersionCheck.Result upgradeResult = check.checkUpgrade(check.configuredVersion(), CursorContext.NULL);
    assertTrue(upgradeResult.outcome.isSuccessful());
    String versionToMigrateFrom = upgradeResult.actualVersion;
    // GIVEN
    {
        StoreUpgrader upgrader = newUpgrader(check, allowMigrateConfig, pageCache);
        String failureMessage = "Just failing";
        upgrader.addParticipant(participantThatWillFailWhenMoving(failureMessage));
        // WHEN
        var e = assertThrows(UnableToUpgradeException.class, () -> upgrader.migrateIfNeeded(databaseLayout, false));
        assertTrue(e.getCause() instanceof IOException);
        assertEquals(failureMessage, e.getCause().getMessage());
    }
    // AND WHEN
    {
        StoreUpgrader upgrader = newUpgrader(check, pageCache);
        StoreMigrationParticipant observingParticipant = Mockito.mock(StoreMigrationParticipant.class);
        upgrader.addParticipant(observingParticipant);
        upgrader.migrateIfNeeded(databaseLayout, false);
        // THEN
        verify(observingParticipant, Mockito.never()).migrate(any(DatabaseLayout.class), any(DatabaseLayout.class), any(ProgressReporter.class), eq(versionToMigrateFrom), eq(versionToMigrateTo), eq(IndexImporterFactory.EMPTY));
        verify(observingParticipant).moveMigratedFiles(any(DatabaseLayout.class), any(DatabaseLayout.class), eq(versionToMigrateFrom), eq(versionToMigrateTo));
        verify(observingParticipant).cleanup(any(DatabaseLayout.class));
    }
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) UnableToUpgradeException(org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException) AbstractStoreMigrationParticipant(org.neo4j.storageengine.migration.AbstractStoreMigrationParticipant) StoreMigrationParticipant(org.neo4j.storageengine.migration.StoreMigrationParticipant) IOException(java.io.IOException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with StoreMigrationParticipant

use of org.neo4j.storageengine.migration.StoreMigrationParticipant in project neo4j by neo4j.

the class StoreUpgrader method migrateToIsolatedDirectory.

private void migrateToIsolatedDirectory(DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, String versionToMigrateFrom) {
    try {
        for (Map.Entry<String, StoreMigrationParticipant> participantEntry : participants.entrySet()) {
            ProgressReporter progressReporter = progressMonitor.startSection(participantEntry.getKey());
            String versionToMigrateTo = storeVersionCheck.configuredVersion();
            IndexImporterFactory indexImporterFactory = new IndexImporterFactoryImpl(config);
            participantEntry.getValue().migrate(directoryLayout, migrationLayout, progressReporter, versionToMigrateFrom, versionToMigrateTo, indexImporterFactory);
            progressReporter.completed();
        }
    } catch (IOException | UncheckedIOException | KernelException e) {
        throw new UnableToUpgradeException("Failure doing migration", e);
    }
}
Also used : StoreMigrationParticipant(org.neo4j.storageengine.migration.StoreMigrationParticipant) IndexImporterFactory(org.neo4j.internal.batchimport.IndexImporterFactory) ProgressReporter(org.neo4j.common.ProgressReporter) UncheckedIOException(java.io.UncheckedIOException) IndexImporterFactoryImpl(org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) KernelException(org.neo4j.exceptions.KernelException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

StoreMigrationParticipant (org.neo4j.storageengine.migration.StoreMigrationParticipant)3 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 Dependencies (org.neo4j.collection.Dependencies)1 ProgressReporter (org.neo4j.common.ProgressReporter)1 Config (org.neo4j.configuration.Config)1 KernelException (org.neo4j.exceptions.KernelException)1 IndexImporterFactory (org.neo4j.internal.batchimport.IndexImporterFactory)1 RecordStorageEngineFactory (org.neo4j.internal.recordstorage.RecordStorageEngineFactory)1 IndexImporterFactoryImpl (org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl)1 LogsUpgrader (org.neo4j.kernel.impl.storemigration.LogsUpgrader)1 StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)1 UnableToUpgradeException (org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException)1 DatabaseHealth (org.neo4j.monitoring.DatabaseHealth)1 Monitors (org.neo4j.monitoring.Monitors)1 StoreVersionCheck (org.neo4j.storageengine.api.StoreVersionCheck)1