Search in sources :

Example 1 with IndexImporterFactory

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);
}
Also used : MigrationProgressMonitor(org.neo4j.storageengine.migration.MigrationProgressMonitor) RecordStoreVersionCheck(org.neo4j.kernel.impl.storemigration.RecordStoreVersionCheck) RecordStorageMigrator(org.neo4j.kernel.impl.storemigration.RecordStorageMigrator) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) IndexImporterFactory(org.neo4j.internal.batchimport.IndexImporterFactory) ProgressReporter(org.neo4j.common.ProgressReporter) IdGeneratorMigrator(org.neo4j.kernel.impl.storemigration.IdGeneratorMigrator) SchemaIndexMigrator(org.neo4j.storageengine.migration.SchemaIndexMigrator) NullLogService(org.neo4j.logging.internal.NullLogService) LogService(org.neo4j.logging.internal.LogService) Test(org.junit.Test)

Example 2 with IndexImporterFactory

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);
}
Also used : Path(java.nio.file.Path) IndexDirectoryStructure(org.neo4j.kernel.api.index.IndexDirectoryStructure) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) StoreVersion(org.neo4j.storageengine.api.StoreVersion) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexImporterFactory(org.neo4j.internal.batchimport.IndexImporterFactory) SchemaIndexMigrator(org.neo4j.storageengine.migration.SchemaIndexMigrator) Test(org.junit.jupiter.api.Test)

Example 3 with IndexImporterFactory

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);
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) ParallelBatchImporter(org.neo4j.internal.batchimport.ParallelBatchImporter) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) BatchImporter(org.neo4j.internal.batchimport.BatchImporter) ParallelBatchImporter(org.neo4j.internal.batchimport.ParallelBatchImporter) Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) IndexImporterFactory(org.neo4j.internal.batchimport.IndexImporterFactory) IndexImporterFactoryImpl(org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler)

Example 4 with IndexImporterFactory

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

IndexImporterFactory (org.neo4j.internal.batchimport.IndexImporterFactory)4 ProgressReporter (org.neo4j.common.ProgressReporter)2 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)2 IndexImporterFactoryImpl (org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl)2 SchemaIndexMigrator (org.neo4j.storageengine.migration.SchemaIndexMigrator)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 Path (java.nio.file.Path)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 Config (org.neo4j.configuration.Config)1 KernelException (org.neo4j.exceptions.KernelException)1 BatchImporter (org.neo4j.internal.batchimport.BatchImporter)1 ParallelBatchImporter (org.neo4j.internal.batchimport.ParallelBatchImporter)1 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)1 IndexDirectoryStructure (org.neo4j.kernel.api.index.IndexDirectoryStructure)1 RecordFormats (org.neo4j.kernel.impl.store.format.RecordFormats)1 IdGeneratorMigrator (org.neo4j.kernel.impl.storemigration.IdGeneratorMigrator)1