Search in sources :

Example 1 with StoreAccess

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

the class RelationshipChainExplorerTest method createStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes.

private StoreAccess createStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes(int nDegreeTwoNodes) {
    File storeDirectory = storeLocation.graphDbDir();
    GraphDatabaseService database = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDirectory).setConfig(GraphDatabaseSettings.record_format, getRecordFormatName()).newGraphDatabase();
    try (Transaction transaction = database.beginTx()) {
        Node denseNode = database.createNode();
        for (int i = 0; i < nDegreeTwoNodes; i++) {
            Node degreeTwoNode = database.createNode();
            Node leafNode = database.createNode();
            if (i % 2 == 0) {
                denseNode.createRelationshipTo(degreeTwoNode, TestRelationshipType.CONNECTED);
            } else {
                degreeTwoNode.createRelationshipTo(denseNode, TestRelationshipType.CONNECTED);
            }
            degreeTwoNode.createRelationshipTo(leafNode, TestRelationshipType.CONNECTED);
        }
        transaction.success();
    }
    database.shutdown();
    PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
    StoreAccess storeAccess = new StoreAccess(fileSystemRule.get(), pageCache, storeDirectory, Config.empty());
    return storeAccess.initialize();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) Node(org.neo4j.graphdb.Node) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache)

Example 2 with StoreAccess

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

the class FullCheckIntegrationTest method shouldReportRelationshipLabelNameInconsistencies.

@Test
public void shouldReportRelationshipLabelNameInconsistencies() throws Exception {
    // given
    final Reference<Integer> inconsistentName = new Reference<>();
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            inconsistentName.set(next.relationshipType());
            tx.relationshipType(inconsistentName.get(), "FOO");
        }
    });
    StoreAccess access = fixture.directStoreAccess().nativeStores();
    DynamicRecord record = access.getRelationshipTypeNameStore().getRecord(inconsistentName.get(), access.getRelationshipTypeNameStore().newRecord(), FORCE);
    record.setNextBlock(record.getId());
    access.getRelationshipTypeNameStore().updateRecord(record);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.RELATIONSHIP_TYPE_NAME, 1).andThatsAllFolks();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 3 with StoreAccess

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

the class FullCheckIntegrationTest method shouldReportLabelInconsistencies.

@Test
public void shouldReportLabelInconsistencies() throws Exception {
    // given
    StoreAccess access = fixture.directStoreAccess().nativeStores();
    LabelTokenRecord record = access.getLabelTokenStore().getRecord(1, access.getLabelTokenStore().newRecord(), FORCE);
    record.setNameId(20);
    record.setInUse(true);
    access.getLabelTokenStore().updateRecord(record);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.LABEL, 1).andThatsAllFolks();
}
Also used : DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 4 with StoreAccess

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

the class FullCheckIntegrationTest method shouldReportPropertyKeyInconsistencies.

@Test
public void shouldReportPropertyKeyInconsistencies() throws Exception {
    // given
    final Reference<Integer> inconsistentKey = new Reference<>();
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            inconsistentKey.set(next.propertyKey());
            tx.propertyKey(inconsistentKey.get(), "FOO");
        }
    });
    StoreAccess access = fixture.directStoreAccess().nativeStores();
    DynamicRecord record = access.getPropertyKeyNameStore().getRecord(inconsistentKey.get() + 1, access.getPropertyKeyNameStore().newRecord(), FORCE);
    record.setInUse(false);
    access.getPropertyKeyNameStore().updateRecord(record);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.PROPERTY_KEY, 1).andThatsAllFolks();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 5 with StoreAccess

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

Aggregations

StoreAccess (org.neo4j.kernel.impl.store.StoreAccess)13 DirectStoreAccess (org.neo4j.kernel.api.direct.DirectStoreAccess)10 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)8 Test (org.junit.Test)7 File (java.io.File)3 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)3 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)3 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)3 AccessStatsKeepingStoreAccess (org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess)3 DefaultCounts (org.neo4j.consistency.statistics.DefaultCounts)3 PageCache (org.neo4j.io.pagecache.PageCache)3 LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)3 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)3 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)3 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)3 IOException (java.io.IOException)2 AccessStatistics (org.neo4j.consistency.statistics.AccessStatistics)2 VerboseStatistics (org.neo4j.consistency.statistics.VerboseStatistics)2 Node (org.neo4j.graphdb.Node)2 Transaction (org.neo4j.graphdb.Transaction)2