Search in sources :

Example 1 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class GraphStoreFixture method directStoreAccess.

public DirectStoreAccess directStoreAccess() {
    if (directStoreAccess == null) {
        fileSystem = new DefaultFileSystemAbstraction();
        PageCache pageCache = getPageCache(fileSystem);
        LogProvider logProvider = NullLogProvider.getInstance();
        StoreFactory storeFactory = new StoreFactory(directory, pageCache, fileSystem, logProvider);
        neoStore = storeFactory.openAllNeoStores();
        StoreAccess nativeStores;
        if (keepStatistics) {
            AccessStatistics accessStatistics = new AccessStatistics();
            statistics = new VerboseStatistics(accessStatistics, new DefaultCounts(defaultConsistencyCheckThreadsNumber()), NullLog.getInstance());
            nativeStores = new AccessStatsKeepingStoreAccess(neoStore, accessStatistics);
        } else {
            statistics = Statistics.NONE;
            nativeStores = new StoreAccess(neoStore);
        }
        nativeStores.initialize();
        Config config = Config.empty();
        OperationalMode operationalMode = OperationalMode.single;
        IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, nativeStores.getRawNeoStores());
        Dependencies dependencies = new Dependencies();
        dependencies.satisfyDependencies(Config.defaults(), fileSystem, new SimpleLogService(logProvider, logProvider), indexStoreView, pageCache);
        KernelContext kernelContext = new SimpleKernelContext(directory, UNKNOWN, dependencies);
        LabelScanStore labelScanStore = startLabelScanStore(config, dependencies, kernelContext);
        directStoreAccess = new DirectStoreAccess(nativeStores, labelScanStore, createIndexes(fileSystem, config, operationalMode));
    }
    return directStoreAccess;
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) Config(org.neo4j.kernel.configuration.Config) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) OperationalMode(org.neo4j.kernel.impl.factory.OperationalMode) NullLogProvider(org.neo4j.logging.NullLogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) LogProvider(org.neo4j.logging.LogProvider) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) DefaultCounts(org.neo4j.consistency.statistics.DefaultCounts) AccessStatistics(org.neo4j.consistency.statistics.AccessStatistics) IndexStoreView(org.neo4j.kernel.impl.api.index.IndexStoreView) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) VerboseStatistics(org.neo4j.consistency.statistics.VerboseStatistics) Dependencies(org.neo4j.kernel.impl.util.Dependencies) PageCache(org.neo4j.io.pagecache.PageCache) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) KernelContext(org.neo4j.kernel.impl.spi.KernelContext)

Example 2 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class GraphStoreFixture method startLabelScanStore.

private LabelScanStore startLabelScanStore(Config config, Dependencies dependencies, KernelContext kernelContext) {
    // Load correct LSS from kernel extensions
    LifeSupport life = new LifeSupport();
    KernelExtensions extensions = life.add(new KernelExtensions(kernelContext, (Iterable) load(KernelExtensionFactory.class), dependencies, ignore()));
    life.start();
    LabelScanStore labelScanStore = extensions.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config)).getLabelScanStore();
    life.shutdown();
    // Start the selected LSS
    try {
        labelScanStore.init();
        labelScanStore.start();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return labelScanStore;
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) KernelExtensions(org.neo4j.kernel.extension.KernelExtensions) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) UncheckedIOException(java.io.UncheckedIOException) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) NamedLabelScanStoreSelectionStrategy(org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy)

Example 3 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class ConsistencyCheckService method runFullConsistencyCheck.

public Result runFullConsistencyCheck(final File storeDir, Config config, ProgressMonitorFactory progressFactory, final LogProvider logProvider, final FileSystemAbstraction fileSystem, final PageCache pageCache, final boolean verbose, File reportDir, CheckConsistencyConfig checkConsistencyConfig) throws ConsistencyCheckIncompleteException {
    Log log = logProvider.getLog(getClass());
    config = config.with(stringMap(GraphDatabaseSettings.read_only.name(), TRUE, GraphDatabaseSettings.label_index.name(), LabelIndex.AUTO.name()));
    StoreFactory factory = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fileSystem), pageCache, fileSystem, logProvider);
    ConsistencySummaryStatistics summary;
    final File reportFile = chooseReportPath(reportDir);
    Log reportLog = new ConsistencyReportLog(Suppliers.lazySingleton(() -> {
        try {
            return new PrintWriter(createOrOpenAsOuputStream(fileSystem, reportFile, true));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }));
    // Bootstrap kernel extensions
    LifeSupport life = new LifeSupport();
    try (NeoStores neoStores = factory.openAllNeoStores()) {
        IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, neoStores);
        Dependencies dependencies = new Dependencies();
        dependencies.satisfyDependencies(config, fileSystem, new SimpleLogService(logProvider, logProvider), indexStoreView, pageCache);
        KernelContext kernelContext = new SimpleKernelContext(storeDir, UNKNOWN, dependencies);
        KernelExtensions extensions = life.add(new KernelExtensions(kernelContext, (Iterable) load(KernelExtensionFactory.class), dependencies, ignore()));
        life.start();
        LabelScanStore labelScanStore = life.add(extensions.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config)).getLabelScanStore());
        SchemaIndexProvider indexes = life.add(extensions.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance()));
        int numberOfThreads = defaultConsistencyCheckThreadsNumber();
        Statistics statistics;
        StoreAccess storeAccess;
        AccessStatistics stats = new AccessStatistics();
        if (verbose) {
            statistics = new VerboseStatistics(stats, new DefaultCounts(numberOfThreads), log);
            storeAccess = new AccessStatsKeepingStoreAccess(neoStores, stats);
        } else {
            statistics = Statistics.NONE;
            storeAccess = new StoreAccess(neoStores);
        }
        storeAccess.initialize();
        DirectStoreAccess stores = new DirectStoreAccess(storeAccess, labelScanStore, indexes);
        FullCheck check = new FullCheck(progressFactory, statistics, numberOfThreads, checkConsistencyConfig);
        summary = check.execute(stores, new DuplicatingLog(log, reportLog));
    } finally {
        life.shutdown();
    }
    if (!summary.isConsistent()) {
        log.warn("See '%s' for a detailed consistency report.", reportFile.getPath());
        return Result.failure(reportFile);
    }
    return Result.success(reportFile);
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) DefaultCounts(org.neo4j.consistency.statistics.DefaultCounts) AccessStatistics(org.neo4j.consistency.statistics.AccessStatistics) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DuplicatingLog(org.neo4j.logging.DuplicatingLog) VerboseStatistics(org.neo4j.consistency.statistics.VerboseStatistics) Dependencies(org.neo4j.kernel.impl.util.Dependencies) NamedLabelScanStoreSelectionStrategy(org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) PrintWriter(java.io.PrintWriter) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) KernelContext(org.neo4j.kernel.impl.spi.KernelContext) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) Log(org.neo4j.logging.Log) DuplicatingLog(org.neo4j.logging.DuplicatingLog) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) IOException(java.io.IOException) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory) Statistics(org.neo4j.consistency.statistics.Statistics) VerboseStatistics(org.neo4j.consistency.statistics.VerboseStatistics) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) AccessStatistics(org.neo4j.consistency.statistics.AccessStatistics) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) FullCheck(org.neo4j.consistency.checking.full.FullCheck) KernelExtensions(org.neo4j.kernel.extension.KernelExtensions) NeoStores(org.neo4j.kernel.impl.store.NeoStores) IndexStoreView(org.neo4j.kernel.impl.api.index.IndexStoreView) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) File(java.io.File)

Example 4 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class MultiIndexPopulationConcurrentUpdatesIT method launchCustomIndexPopulation.

private void launchCustomIndexPopulation(Map<String, Integer> labelNameIdMap, int propertyId, List<NodeUpdates> updates) throws Exception {
    NeoStores neoStores = getNeoStores();
    LabelScanStore labelScanStore = getLabelScanStore();
    ThreadToStatementContextBridge transactionStatementContextBridge = getTransactionStatementContextBridge();
    try (Transaction transaction = embeddedDatabase.beginTx()) {
        Statement statement = transactionStatementContextBridge.get();
        DynamicIndexStoreView storeView = new DynamicIndexStoreViewWrapper(labelScanStore, LockService.NO_LOCK_SERVICE, neoStores, updates);
        SchemaIndexProviderMap providerMap = new DefaultSchemaIndexProviderMap(getSchemaIndexProvider());
        JobScheduler scheduler = getJobScheduler();
        StatementTokenNameLookup tokenNameLookup = new StatementTokenNameLookup(statement.readOperations());
        indexService = IndexingServiceFactory.createIndexingService(Config.empty(), scheduler, providerMap, storeView, tokenNameLookup, getIndexRules(neoStores), NullLogProvider.getInstance(), IndexingService.NO_MONITOR, () -> {
        });
        indexService.start();
        IndexRule[] rules = createIndexRules(labelNameIdMap, propertyId);
        indexService.createIndexes(rules);
        transaction.success();
    }
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) StatementTokenNameLookup(org.neo4j.kernel.api.StatementTokenNameLookup) Statement(org.neo4j.kernel.api.Statement) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) DynamicIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.DynamicIndexStoreView) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) SchemaIndexProviderMap(org.neo4j.kernel.impl.api.index.SchemaIndexProviderMap) Transaction(org.neo4j.graphdb.Transaction) NeoStores(org.neo4j.kernel.impl.store.NeoStores)

Example 5 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class NeoStoreFileListingTest method shouldCloseIndexAndLabelScanSnapshots.

@Test
public void shouldCloseIndexAndLabelScanSnapshots() throws Exception {
    // Given
    LabelScanStore labelScanStore = mock(LabelScanStore.class);
    IndexingService indexingService = mock(IndexingService.class);
    LegacyIndexProviderLookup legacyIndexes = mock(LegacyIndexProviderLookup.class);
    when(legacyIndexes.all()).thenReturn(Collections.emptyList());
    File storeDir = mock(File.class);
    filesInStoreDirAre(storeDir, STANDARD_STORE_DIR_FILES, STANDARD_STORE_DIR_DIRECTORIES);
    StorageEngine storageEngine = mock(StorageEngine.class);
    NeoStoreFileListing fileListing = new NeoStoreFileListing(storeDir, labelScanStore, indexingService, legacyIndexes, storageEngine);
    ResourceIterator<File> scanSnapshot = scanStoreFilesAre(labelScanStore, new String[] { "blah/scan.store", "scan.more" });
    ResourceIterator<File> indexSnapshot = indexFilesAre(indexingService, new String[] { "schema/index/my.index" });
    ResourceIterator<StoreFileMetadata> result = fileListing.listStoreFiles(false);
    // When
    result.close();
    // Then
    verify(scanSnapshot).close();
    verify(indexSnapshot).close();
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) LegacyIndexProviderLookup(org.neo4j.kernel.impl.api.LegacyIndexProviderLookup) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) StoreFileMetadata(org.neo4j.storageengine.api.StoreFileMetadata) StorageEngine(org.neo4j.storageengine.api.StorageEngine) StoreFile(org.neo4j.kernel.impl.storemigration.StoreFile) File(java.io.File) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) Test(org.junit.Test)

Aggregations

LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)9 IOException (java.io.IOException)4 File (java.io.File)3 Test (org.junit.Test)3 AccessStatistics (org.neo4j.consistency.statistics.AccessStatistics)2 AccessStatsKeepingStoreAccess (org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess)2 DefaultCounts (org.neo4j.consistency.statistics.DefaultCounts)2 VerboseStatistics (org.neo4j.consistency.statistics.VerboseStatistics)2 DirectStoreAccess (org.neo4j.kernel.api.direct.DirectStoreAccess)2 LabelScanStoreTest (org.neo4j.kernel.api.impl.labelscan.LabelScanStoreTest)2 KernelExtensionFactory (org.neo4j.kernel.extension.KernelExtensionFactory)2 KernelExtensions (org.neo4j.kernel.extension.KernelExtensions)2 NamedLabelScanStoreSelectionStrategy (org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy)2 IndexStoreView (org.neo4j.kernel.impl.api.index.IndexStoreView)2 SimpleLogService (org.neo4j.kernel.impl.logging.SimpleLogService)2 KernelContext (org.neo4j.kernel.impl.spi.KernelContext)2 SimpleKernelContext (org.neo4j.kernel.impl.spi.SimpleKernelContext)2 NeoStores (org.neo4j.kernel.impl.store.NeoStores)2 StoreAccess (org.neo4j.kernel.impl.store.StoreAccess)2 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)2