Search in sources :

Example 1 with StoreFactory

use of org.neo4j.kernel.impl.store.StoreFactory 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 StoreFactory

use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.

the class DumpStoreChain method dump.

void dump(File storeDir) throws IOException {
    try (DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction();
        PageCache pageCache = createPageCache(fs)) {
        DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
        Config config = Config.defaults();
        StoreFactory storeFactory = new StoreFactory(storeDir, config, idGeneratorFactory, pageCache, fs, logProvider());
        try (NeoStores neoStores = storeFactory.openNeoStores(getStoreTypes())) {
            RecordStore<RECORD> store = store(neoStores);
            RECORD record = store.newRecord();
            for (long next = first; next != -1; ) {
                store.getRecord(next, record, RecordLoad.FORCE);
                System.out.println(record);
                next = next(record);
            }
        }
    }
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) NeoStores(org.neo4j.kernel.impl.store.NeoStores) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) StandalonePageCacheFactory.createPageCache(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory.createPageCache) PageCache(org.neo4j.io.pagecache.PageCache)

Example 3 with StoreFactory

use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.

the class RsdrMain method main.

public static void main(String[] args) throws IOException {
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
        console.printf("Neo4j Raw Store Diagnostics Reader%n");
        if (args.length != 1 || !fileSystem.isDirectory(new File(args[0]))) {
            console.printf("Usage: rsdr <store directory>%n");
            return;
        }
        File storedir = new File(args[0]);
        Config config = buildConfig();
        try (PageCache pageCache = createPageCache(fileSystem, config)) {
            File neoStore = new File(storedir, MetaDataStore.DEFAULT_NAME);
            StoreFactory factory = openStore(fileSystem, neoStore, config, pageCache);
            NeoStores neoStores = factory.openAllNeoStores();
            interact(fileSystem, neoStores);
        }
    }
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) ConfigurableStandalonePageCacheFactory.createPageCache(org.neo4j.kernel.impl.pagecache.ConfigurableStandalonePageCacheFactory.createPageCache)

Example 4 with StoreFactory

use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.

the class DumpCountsStore method dumpCountsStore.

public static void dumpCountsStore(FileSystemAbstraction fs, File path, PrintStream out) throws IOException {
    try (PageCache pages = createPageCache(fs);
        Lifespan life = new Lifespan()) {
        if (fs.isDirectory(path)) {
            StoreFactory factory = new StoreFactory(path, pages, fs, NullLogProvider.getInstance());
            NeoStores neoStores = factory.openAllNeoStores();
            SchemaStorage schemaStorage = new SchemaStorage(neoStores.getSchemaStore());
            neoStores.getCounts().accept(new DumpCountsStore(out, neoStores, schemaStorage));
        } else {
            VisitableCountsTracker tracker = new VisitableCountsTracker(NullLogProvider.getInstance(), fs, pages, Config.empty(), path);
            if (fs.fileExists(path)) {
                tracker.visitFile(path, new DumpCountsStore(out));
            } else {
                life.add(tracker).accept(new DumpCountsStore(out));
            }
        }
    }
}
Also used : SchemaStorage(org.neo4j.kernel.impl.store.SchemaStorage) NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) StandalonePageCacheFactory.createPageCache(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory.createPageCache) PageCache(org.neo4j.io.pagecache.PageCache)

Example 5 with StoreFactory

use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.

the class OnDiskLastTxIdGetterTest method lastTransactionIdIsBaseTxIdWhileNeoStoresAreStopped.

@Test
public void lastTransactionIdIsBaseTxIdWhileNeoStoresAreStopped() {
    final StoreFactory storeFactory = new StoreFactory(new File("store"), pageCacheRule.getPageCache(fs.get()), fs.get(), NullLogProvider.getInstance());
    final NeoStores neoStores = storeFactory.openAllNeoStores(true);
    neoStores.close();
    LongSupplier supplier = () -> neoStores.getMetaDataStore().getLastCommittedTransactionId();
    OnDiskLastTxIdGetter diskLastTxIdGetter = new OnDiskLastTxIdGetter(supplier);
    assertEquals(TransactionIdStore.BASE_TX_ID, diskLastTxIdGetter.getLastTxId());
}
Also used : OnDiskLastTxIdGetter(org.neo4j.kernel.ha.transaction.OnDiskLastTxIdGetter) NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) LongSupplier(java.util.function.LongSupplier) File(java.io.File) Test(org.junit.Test)

Aggregations

StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)64 NeoStores (org.neo4j.kernel.impl.store.NeoStores)31 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)30 File (java.io.File)18 BeforeEach (org.junit.jupiter.api.BeforeEach)15 PageCache (org.neo4j.io.pagecache.PageCache)12 DefaultIdGeneratorFactory (org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 MethodSource (org.junit.jupiter.params.provider.MethodSource)7 IOException (java.io.IOException)6 Path (java.nio.file.Path)6 Before (org.junit.Before)6 Test (org.junit.Test)6 Config (org.neo4j.configuration.Config)6 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)6 CursorContext (org.neo4j.io.pagecache.context.CursorContext)6 Config (org.neo4j.kernel.configuration.Config)6 LogProvider (org.neo4j.logging.LogProvider)6 NullLogProvider (org.neo4j.logging.NullLogProvider)6 ScanOnOpenOverwritingIdGeneratorFactory (org.neo4j.internal.id.ScanOnOpenOverwritingIdGeneratorFactory)5