Search in sources :

Example 1 with DefaultCacheAccess

use of org.neo4j.consistency.checking.cache.DefaultCacheAccess in project neo4j by neo4j.

the class FullCheck method execute.

ConsistencySummaryStatistics execute(DirectStoreAccess stores, Log log, Monitor reportMonitor) throws ConsistencyCheckIncompleteException {
    ConsistencySummaryStatistics summary = new ConsistencySummaryStatistics();
    InconsistencyReport report = new InconsistencyReport(new InconsistencyMessageLogger(log), summary);
    OwnerCheck ownerCheck = new OwnerCheck(checkPropertyOwners);
    CountsBuilderDecorator countsBuilder = new CountsBuilderDecorator(stores.nativeStores());
    CheckDecorator decorator = new CheckDecorator.ChainCheckDecorator(ownerCheck, countsBuilder);
    CacheAccess cacheAccess = new DefaultCacheAccess(statistics.getCounts(), threads);
    RecordAccess records = recordAccess(stores.nativeStores(), cacheAccess);
    execute(stores, decorator, records, report, cacheAccess, reportMonitor);
    ownerCheck.scanForOrphanChains(progressFactory);
    if (checkGraph) {
        CountsAccessor countsAccessor = stores.nativeStores().getCounts();
        if (countsAccessor instanceof CountsTracker) {
            CountsTracker tracker = (CountsTracker) countsAccessor;
            try {
                tracker.start();
            } catch (Exception e) {
            // let's hope it was already started :)
            }
        }
        countsBuilder.checkCounts(countsAccessor, new ConsistencyReporter(records, report), progressFactory);
    }
    if (!summary.isConsistent()) {
        log.warn("Inconsistencies found: " + summary);
    }
    return summary;
}
Also used : DirectRecordAccess(org.neo4j.consistency.store.DirectRecordAccess) CacheSmallStoresRecordAccess(org.neo4j.consistency.store.CacheSmallStoresRecordAccess) RecordAccess(org.neo4j.consistency.store.RecordAccess) InconsistencyReport(org.neo4j.consistency.report.InconsistencyReport) ConsistencyReporter(org.neo4j.consistency.report.ConsistencyReporter) CacheAccess(org.neo4j.consistency.checking.cache.CacheAccess) DefaultCacheAccess(org.neo4j.consistency.checking.cache.DefaultCacheAccess) CountsAccessor(org.neo4j.kernel.impl.api.CountsAccessor) DefaultCacheAccess(org.neo4j.consistency.checking.cache.DefaultCacheAccess) CheckDecorator(org.neo4j.consistency.checking.CheckDecorator) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) InconsistencyMessageLogger(org.neo4j.consistency.report.InconsistencyMessageLogger) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics)

Example 2 with DefaultCacheAccess

use of org.neo4j.consistency.checking.cache.DefaultCacheAccess in project neo4j by neo4j.

the class CountsStateTest method setUp.

@BeforeEach
void setUp() {
    cacheAccess = new DefaultCacheAccess(HEAP.newByteArray(HIGH_NODE_ID, new byte[MAX_SLOT_BITS], INSTANCE), Counts.NONE, 1);
    cacheAccess.setCacheSlotSizes(DEFAULT_SLOT_SIZES);
    countsState = new CountsState(HIGH_TOKEN_ID, HIGH_TOKEN_ID, HIGH_NODE_ID, cacheAccess, INSTANCE);
    noConsistencyReporter = mock(ConsistencyReporter.class);
    when(noConsistencyReporter.forCounts(any())).thenReturn(mock(ConsistencyReport.CountsConsistencyReport.class));
    inconsistencyReporter = mock(ConsistencyReporter.class);
    when(inconsistencyReporter.forCounts(any())).thenReturn(mock(ConsistencyReport.CountsConsistencyReport.class));
    race = new Race().withEndCondition(() -> false);
}
Also used : ConsistencyReporter(org.neo4j.consistency.report.ConsistencyReporter) Race(org.neo4j.test.Race) DefaultCacheAccess(org.neo4j.consistency.checking.cache.DefaultCacheAccess) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DefaultCacheAccess

use of org.neo4j.consistency.checking.cache.DefaultCacheAccess in project neo4j by neo4j.

the class ExecutionOrderIntegrationTest method shouldRunChecksInSingleThreadedPass.

@Test
public void shouldRunChecksInSingleThreadedPass() throws Exception {
    // given
    StoreAccess store = fixture.directStoreAccess().nativeStores();
    int threads = defaultConsistencyCheckThreadsNumber();
    CacheAccess cacheAccess = new DefaultCacheAccess(new DefaultCounts(threads), threads);
    RecordAccess access = FullCheck.recordAccess(store, cacheAccess);
    FullCheck singlePass = new FullCheck(getTuningConfiguration(), ProgressMonitorFactory.NONE, Statistics.NONE, threads);
    ConsistencySummaryStatistics singlePassSummary = new ConsistencySummaryStatistics();
    InconsistencyLogger logger = mock(InconsistencyLogger.class);
    InvocationLog singlePassChecks = new InvocationLog();
    // when
    singlePass.execute(fixture.directStoreAccess(), new LogDecorator(singlePassChecks), access, new InconsistencyReport(logger, singlePassSummary), cacheAccess, NO_MONITOR);
    // then
    verifyZeroInteractions(logger);
    assertEquals("Expected no inconsistencies in single pass.", 0, singlePassSummary.getTotalInconsistencyCount());
}
Also used : DefaultCounts(org.neo4j.consistency.statistics.DefaultCounts) RecordAccess(org.neo4j.consistency.store.RecordAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) InconsistencyReport(org.neo4j.consistency.report.InconsistencyReport) CacheAccess(org.neo4j.consistency.checking.cache.CacheAccess) DefaultCacheAccess(org.neo4j.consistency.checking.cache.DefaultCacheAccess) InconsistencyLogger(org.neo4j.consistency.report.InconsistencyLogger) DefaultCacheAccess(org.neo4j.consistency.checking.cache.DefaultCacheAccess) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 4 with DefaultCacheAccess

use of org.neo4j.consistency.checking.cache.DefaultCacheAccess in project neo4j by neo4j.

the class CheckerTestBase method setUpDb.

@BeforeEach
void setUpDb() throws Exception {
    TestDatabaseManagementServiceBuilder builder = new TestDatabaseManagementServiceBuilder(directory.homePath());
    builder.setFileSystem(directory.getFileSystem());
    dbms = builder.build();
    db = (GraphDatabaseAPI) dbms.database(GraphDatabaseSettings.DEFAULT_DATABASE_NAME);
    // Create our tokens
    Kernel kernel = db.getDependencyResolver().resolveDependency(Kernel.class);
    try (KernelTransaction tx = kernel.beginTransaction(KernelTransaction.Type.EXPLICIT, LoginContext.AUTH_DISABLED)) {
        initialData(tx);
        tx.commit();
    }
    DependencyResolver dependencies = db.getDependencyResolver();
    neoStores = dependencies.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
    nodeStore = neoStores.getNodeStore();
    relationshipGroupStore = neoStores.getRelationshipGroupStore();
    propertyStore = neoStores.getPropertyStore();
    relationshipStore = neoStores.getRelationshipStore();
    schemaStore = neoStores.getSchemaStore();
    tokenHolders = dependencies.resolveDependency(TokenHolders.class);
    schemaStorage = new SchemaStorage(schemaStore, tokenHolders, neoStores.getMetaDataStore());
    cacheAccess = new DefaultCacheAccess(NumberArrayFactories.HEAP.newDynamicByteArray(10_000, new byte[MAX_BYTES], INSTANCE), Counts.NONE, NUMBER_OF_THREADS);
    cacheAccess.setCacheSlotSizes(DEFAULT_SLOT_SIZES);
    pageCache = dependencies.resolveDependency(PageCache.class);
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) SchemaStorage(org.neo4j.internal.recordstorage.SchemaStorage) TokenHolders(org.neo4j.token.TokenHolders) Kernel(org.neo4j.kernel.api.Kernel) PageCache(org.neo4j.io.pagecache.PageCache) DependencyResolver(org.neo4j.common.DependencyResolver) DefaultCacheAccess(org.neo4j.consistency.checking.cache.DefaultCacheAccess) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DefaultCacheAccess (org.neo4j.consistency.checking.cache.DefaultCacheAccess)4 BeforeEach (org.junit.jupiter.api.BeforeEach)2 CacheAccess (org.neo4j.consistency.checking.cache.CacheAccess)2 ConsistencyReporter (org.neo4j.consistency.report.ConsistencyReporter)2 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)2 InconsistencyReport (org.neo4j.consistency.report.InconsistencyReport)2 RecordAccess (org.neo4j.consistency.store.RecordAccess)2 Test (org.junit.Test)1 DependencyResolver (org.neo4j.common.DependencyResolver)1 CheckDecorator (org.neo4j.consistency.checking.CheckDecorator)1 InconsistencyLogger (org.neo4j.consistency.report.InconsistencyLogger)1 InconsistencyMessageLogger (org.neo4j.consistency.report.InconsistencyMessageLogger)1 DefaultCounts (org.neo4j.consistency.statistics.DefaultCounts)1 CacheSmallStoresRecordAccess (org.neo4j.consistency.store.CacheSmallStoresRecordAccess)1 DirectRecordAccess (org.neo4j.consistency.store.DirectRecordAccess)1 SchemaStorage (org.neo4j.internal.recordstorage.SchemaStorage)1 PageCache (org.neo4j.io.pagecache.PageCache)1 Kernel (org.neo4j.kernel.api.Kernel)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1 CountsAccessor (org.neo4j.kernel.impl.api.CountsAccessor)1