Search in sources :

Example 1 with LabelScanStoreProvider

use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.

the class StoreMigration method run.

public void run(final FileSystemAbstraction fs, final File storeDirectory, Config config, LogProvider userLogProvider) throws IOException {
    StoreLogService logService = StoreLogService.withUserLogProvider(userLogProvider).inLogsDirectory(fs, storeDirectory);
    VisibleMigrationProgressMonitor progressMonitor = new VisibleMigrationProgressMonitor(logService.getUserLog(StoreMigration.class));
    LifeSupport life = new LifeSupport();
    life.add(logService);
    // Add participants from kernel extensions...
    LegacyIndexProvider legacyIndexProvider = new LegacyIndexProvider();
    Log log = userLogProvider.getLog(StoreMigration.class);
    try (PageCache pageCache = createPageCache(fs, config)) {
        Dependencies deps = new Dependencies();
        deps.satisfyDependencies(fs, config, legacyIndexProvider, pageCache, logService);
        KernelContext kernelContext = new SimpleKernelContext(storeDirectory, DatabaseInfo.UNKNOWN, deps);
        KernelExtensions kernelExtensions = life.add(new KernelExtensions(kernelContext, GraphDatabaseDependencies.newDependencies().kernelExtensions(), deps, ignore()));
        // Add the kernel store migrator
        life.start();
        SchemaIndexProvider schemaIndexProvider = kernelExtensions.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance());
        LabelScanStoreProvider labelScanStoreProvider = kernelExtensions.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config));
        long startTime = System.currentTimeMillis();
        DatabaseMigrator migrator = new DatabaseMigrator(progressMonitor, fs, config, logService, schemaIndexProvider, labelScanStoreProvider, legacyIndexProvider.getIndexProviders(), pageCache, RecordFormatSelector.selectForConfig(config, userLogProvider));
        migrator.migrate(storeDirectory);
        long duration = System.currentTimeMillis() - startTime;
        log.info(format("Migration completed in %d s%n", duration / 1000));
    } catch (Exception e) {
        throw new StoreUpgrader.UnableToUpgradeException("Failure during upgrade", e);
    } finally {
        life.shutdown();
    }
}
Also used : SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) VisibleMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor) StoreLogService(org.neo4j.kernel.impl.logging.StoreLogService) Log(org.neo4j.logging.Log) IOException(java.io.IOException) DatabaseMigrator(org.neo4j.kernel.impl.storemigration.DatabaseMigrator) KernelExtensions(org.neo4j.kernel.extension.KernelExtensions) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) Dependencies(org.neo4j.kernel.impl.util.Dependencies) GraphDatabaseDependencies(org.neo4j.kernel.GraphDatabaseDependencies) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) NamedLabelScanStoreSelectionStrategy(org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy) PageCache(org.neo4j.io.pagecache.PageCache) ConfigurableStandalonePageCacheFactory.createPageCache(org.neo4j.kernel.impl.pagecache.ConfigurableStandalonePageCacheFactory.createPageCache) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) KernelContext(org.neo4j.kernel.impl.spi.KernelContext)

Example 2 with LabelScanStoreProvider

use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.

the class NamedLabelScanStoreSelectionStrategyTest method shouldSelectSpecificallyConfiguredProviderAmongMultiple.

@Test
public void shouldSelectSpecificallyConfiguredProviderAmongMultiple() throws Exception {
    // GIVEN
    NamedLabelScanStoreSelectionStrategy strategy = strategy(LabelIndex.LUCENE);
    LabelScanStoreProvider nativeProvider = provider(LabelIndex.NATIVE, store(false));
    LabelScanStoreProvider luceneProvider = provider(LabelIndex.LUCENE, store(false));
    // WHEN
    LabelScanStoreProvider selected = select(strategy, nativeProvider, luceneProvider);
    // THEN
    assertSame(luceneProvider, selected);
}
Also used : LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) Test(org.junit.Test)

Example 3 with LabelScanStoreProvider

use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.

the class NamedLabelScanStoreSelectionStrategyTest method shouldFailAutoSelectIfMultipleProvidersWithPresentStore.

@Test
public void shouldFailAutoSelectIfMultipleProvidersWithPresentStore() throws Exception {
    // GIVEN
    NamedLabelScanStoreSelectionStrategy strategy = strategy(LabelIndex.AUTO);
    LabelScanStoreProvider nativeProvider = provider(LabelIndex.NATIVE, store(true));
    LabelScanStoreProvider luceneProvider = provider(LabelIndex.LUCENE, store(true));
    // WHEN
    try {
        select(strategy, nativeProvider, luceneProvider);
        fail("Should've failed");
    } catch (IllegalArgumentException e) {
    // THEN good
    }
}
Also used : LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) Test(org.junit.Test)

Example 4 with LabelScanStoreProvider

use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.

the class NamedLabelScanStoreSelectionStrategyTest method shouldFailAutoSelectIfNoProviderWithPresentStoreAndSomeReportedIOException.

@Test
public void shouldFailAutoSelectIfNoProviderWithPresentStoreAndSomeReportedIOException() throws Exception {
    // GIVEN
    NamedLabelScanStoreSelectionStrategy strategy = strategy(LabelIndex.AUTO);
    LabelScanStoreProvider nativeProvider = provider(LabelIndex.NATIVE, store(false));
    LabelScanStoreProvider luceneProvider = provider(LabelIndex.LUCENE, store(null));
    // WHEN
    try {
        select(strategy, nativeProvider, luceneProvider);
        fail("Should've failed");
    } catch (IllegalArgumentException e) {
        // THEN good
        assertTrue(e.getCause() instanceof IOException);
    }
}
Also used : LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with LabelScanStoreProvider

use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.

the class NeoStoreDataSourceRule method getDataSource.

public NeoStoreDataSource getDataSource(File storeDir, FileSystemAbstraction fs, IdGeneratorFactory idGeneratorFactory, IdTypeConfigurationProvider idConfigurationProvider, PageCache pageCache, Config config, DatabaseHealth databaseHealth, LogService logService) {
    if (dataSource != null) {
        dataSource.stop();
        dataSource.shutdown();
    }
    StatementLocksFactory locksFactory = mock(StatementLocksFactory.class);
    StatementLocks statementLocks = mock(StatementLocks.class);
    Locks.Client locks = mock(Locks.Client.class);
    when(statementLocks.optimistic()).thenReturn(locks);
    when(statementLocks.pessimistic()).thenReturn(locks);
    when(locksFactory.newInstance()).thenReturn(statementLocks);
    JobScheduler jobScheduler = mock(JobScheduler.class, RETURNS_MOCKS);
    Monitors monitors = new Monitors();
    LabelScanStoreProvider labelScanStoreProvider = nativeLabelScanStoreProvider(storeDir, fs, pageCache, config, logService);
    SystemNanoClock clock = Clocks.nanoClock();
    dataSource = new NeoStoreDataSource(storeDir, config, idGeneratorFactory, IdReuseEligibility.ALWAYS, idConfigurationProvider, logService, mock(JobScheduler.class, RETURNS_MOCKS), mock(TokenNameLookup.class), dependencyResolverForNoIndexProvider(labelScanStoreProvider), mock(PropertyKeyTokenHolder.class), mock(LabelTokenHolder.class), mock(RelationshipTypeTokenHolder.class), locksFactory, mock(SchemaWriteGuard.class), mock(TransactionEventHandlers.class), IndexingService.NO_MONITOR, fs, mock(TransactionMonitor.class), databaseHealth, mock(PhysicalLogFile.Monitor.class), TransactionHeaderInformationFactory.DEFAULT, new StartupStatisticsProvider(), null, new CommunityCommitProcessFactory(), mock(InternalAutoIndexing.class), pageCache, new StandardConstraintSemantics(), monitors, new Tracers("null", NullLog.getInstance(), monitors, jobScheduler), mock(Procedures.class), IOLimiter.unlimited(), new AvailabilityGuard(clock, NullLog.getInstance()), clock, new CanWrite(), new StoreCopyCheckPointMutex());
    return dataSource;
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) NeoStoreDataSource(org.neo4j.kernel.NeoStoreDataSource) Locks(org.neo4j.kernel.impl.locking.Locks) StatementLocks(org.neo4j.kernel.impl.locking.StatementLocks) AvailabilityGuard(org.neo4j.kernel.AvailabilityGuard) StartupStatisticsProvider(org.neo4j.kernel.impl.core.StartupStatisticsProvider) CanWrite(org.neo4j.kernel.impl.factory.CanWrite) SystemNanoClock(org.neo4j.time.SystemNanoClock) StatementLocksFactory(org.neo4j.kernel.impl.locking.StatementLocksFactory) StatementLocks(org.neo4j.kernel.impl.locking.StatementLocks) Monitors(org.neo4j.kernel.monitoring.Monitors) StoreCopyCheckPointMutex(org.neo4j.kernel.impl.transaction.log.checkpoint.StoreCopyCheckPointMutex) CommunityCommitProcessFactory(org.neo4j.kernel.impl.factory.CommunityCommitProcessFactory) StandardConstraintSemantics(org.neo4j.kernel.impl.constraints.StandardConstraintSemantics) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) Tracers(org.neo4j.kernel.monitoring.tracing.Tracers)

Aggregations

LabelScanStoreProvider (org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider)17 Test (org.junit.Test)9 IOException (java.io.IOException)4 Dependencies (org.neo4j.kernel.impl.util.Dependencies)3 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)2 Config (org.neo4j.kernel.configuration.Config)2 NamedLabelScanStoreSelectionStrategy (org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy)2 StandardConstraintSemantics (org.neo4j.kernel.impl.constraints.StandardConstraintSemantics)2 IndexConfigStore (org.neo4j.kernel.impl.index.IndexConfigStore)2 KernelContext (org.neo4j.kernel.impl.spi.KernelContext)2 SimpleKernelContext (org.neo4j.kernel.impl.spi.SimpleKernelContext)2 VisibleMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor)2 SynchronizedArrayIdOrderingQueue (org.neo4j.kernel.impl.util.SynchronizedArrayIdOrderingQueue)2 ArrayList (java.util.ArrayList)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 PageCache (org.neo4j.io.pagecache.PageCache)1 AvailabilityGuard (org.neo4j.kernel.AvailabilityGuard)1 GraphDatabaseDependencies (org.neo4j.kernel.GraphDatabaseDependencies)1 NeoStoreDataSource (org.neo4j.kernel.NeoStoreDataSource)1 KernelException (org.neo4j.kernel.api.exceptions.KernelException)1