use of org.neo4j.internal.batchimport.IndexImporterFactory in project neo4j by neo4j.
the class StoreUpgraderInterruptionTestIT method shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration.
@Test
public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration() throws IOException, ConsistencyCheckIncompleteException {
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, workingDatabaseLayout.databaseDirectory(), prepareDirectory);
RecordStoreVersionCheck versionCheck = new RecordStoreVersionCheck(fs, pageCache, workingDatabaseLayout, NullLogProvider.getInstance(), Config.defaults(), NULL);
MigrationProgressMonitor progressMonitor = MigrationProgressMonitor.SILENT;
LogService logService = NullLogService.getInstance();
RecordStorageMigrator failingStoreMigrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, NULL, batchImporterFactory, INSTANCE) {
@Override
public void migrate(DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressReporter, String versionToMigrateFrom, String versionToMigrateTo, IndexImporterFactory indexImporterFactory) throws IOException, KernelException {
super.migrate(directoryLayout, migrationLayout, progressReporter, versionToMigrateFrom, versionToMigrateTo, indexImporterFactory);
throw new RuntimeException("This upgrade is failing");
}
};
try {
newUpgrader(versionCheck, progressMonitor, createIndexMigrator(), failingStoreMigrator).migrateIfNeeded(workingDatabaseLayout, false);
fail("Should throw exception");
} catch (RuntimeException e) {
assertEquals("This upgrade is failing", e.getMessage());
}
assertTrue(checkNeoStoreHasFormatVersion(versionCheck, baselineFormat));
RecordStorageMigrator migrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, NULL, batchImporterFactory, INSTANCE);
IdGeneratorMigrator idMigrator = new IdGeneratorMigrator(fs, pageCache, CONFIG, NULL);
SchemaIndexMigrator indexMigrator = createIndexMigrator();
newUpgrader(versionCheck, progressMonitor, indexMigrator, migrator, idMigrator).migrateIfNeeded(workingDatabaseLayout, false);
assertTrue(checkNeoStoreHasFormatVersion(versionCheck, successorFormat));
// Since consistency checker is in read only mode we need to start/stop db to generate label scan store.
startStopDatabase(neo4jLayout.homeDirectory());
assertConsistentStore(workingDatabaseLayout);
}
use of org.neo4j.internal.batchimport.IndexImporterFactory in project neo4j by neo4j.
the class SchemaIndexMigratorTest method schemaAndLabelIndexesRemovedAfterSuccessfulMigration.
@Test
void schemaAndLabelIndexesRemovedAfterSuccessfulMigration() throws IOException {
StorageEngineFactory storageEngineFactory = mock(StorageEngineFactory.class);
StoreVersion version = mock(StoreVersion.class);
when(version.hasCompatibleCapabilities(any(), eq(CapabilityType.INDEX))).thenReturn(false);
when(storageEngineFactory.versionInformation(anyString())).thenReturn(version);
IndexImporterFactory indexImporterFactory = mock(IndexImporterFactory.class);
IndexDirectoryStructure directoryStructure = mock(IndexDirectoryStructure.class);
Path indexProviderRootDirectory = databaseLayout.file("just-some-directory");
when(directoryStructure.rootDirectory()).thenReturn(indexProviderRootDirectory);
SchemaIndexMigrator migrator = new SchemaIndexMigrator("Test migrator", fs, pageCache, directoryStructure, storageEngineFactory, true);
when(indexProvider.getProviderDescriptor()).thenReturn(new IndexProviderDescriptor("key", "version"));
migrator.migrate(databaseLayout, migrationLayout, progressReporter, "from", "to", indexImporterFactory);
migrator.moveMigratedFiles(migrationLayout, databaseLayout, "from", "to");
verify(fs).deleteRecursively(indexProviderRootDirectory);
}
use of org.neo4j.internal.batchimport.IndexImporterFactory in project neo4j by neo4j.
the class MultipleIndexPopulationStressIT method createRandomData.
private void createRandomData(long nodeCount, long relCount) throws Exception {
Config config = Config.defaults(neo4j_home, directory.homePath());
RecordFormats recordFormats = RecordFormatSelector.selectForConfig(config, NullLogProvider.getInstance());
try (RandomDataInput input = new RandomDataInput(nodeCount, relCount);
JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
DatabaseLayout layout = Neo4jLayout.of(directory.homePath()).databaseLayout(DEFAULT_DATABASE_NAME);
IndexImporterFactory indexImporterFactory = new IndexImporterFactoryImpl(config);
BatchImporter importer = new ParallelBatchImporter(layout, fileSystemAbstraction, PageCacheTracer.NULL, DEFAULT, NullLogService.getInstance(), ExecutionMonitor.INVISIBLE, EMPTY, config, recordFormats, NO_MONITOR, jobScheduler, Collector.EMPTY, TransactionLogInitializer.getLogFilesInitializer(), indexImporterFactory, INSTANCE);
importer.doImport(input);
}
}
use of org.neo4j.internal.batchimport.IndexImporterFactory 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