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;
}
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));
}
}
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);
}
}
Aggregations