Search in sources :

Example 1 with RecordAccess

use of org.neo4j.consistency.store.RecordAccess in project neo4j by neo4j.

the class MultiPassStoreTest method shouldSkipOtherKindsOfRecords.

@Test
public void shouldSkipOtherKindsOfRecords() throws Exception {
    // given
    RecordAccess recordAccess = mock(RecordAccess.class);
    // when
    List<RecordAccess> filters = multiPassStore().multiPassFilters(recordAccess, MultiPassStore.values());
    // then
    for (RecordAccess filter : filters) {
        for (long id : new long[] { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900 }) {
            otherRecords(filter, id);
        }
    }
    verifyZeroInteractions(recordAccess);
}
Also used : RecordAccess(org.neo4j.consistency.store.RecordAccess) Test(org.junit.Test)

Example 2 with RecordAccess

use of org.neo4j.consistency.store.RecordAccess 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 3 with RecordAccess

use of org.neo4j.consistency.store.RecordAccess in project neo4j by neo4j.

the class OwnerCheck method decoratePropertyChecker.

@Override
public RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> decoratePropertyChecker(final RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> checker) {
    if (owners == null && dynamics == null) {
        return checker;
    }
    return new RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport>() {

        @Override
        public void check(PropertyRecord record, CheckerEngine<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> engine, RecordAccess records) {
            if (record.inUse()) {
                if (owners != null && Record.NO_PREVIOUS_PROPERTY.is(record.getPrevProp())) {
                    // this record is first in a chain
                    PropertyOwner.UnknownOwner owner = new PropertyOwner.UnknownOwner();
                    engine.comparativeCheck(owner, ORPHAN_CHECKER);
                    if (null == owners.putIfAbsent(record.getId(), owner)) {
                        owner.markInCustody();
                    }
                }
                if (dynamics != null) {
                    for (PropertyBlock block : record) {
                        RecordType type = recordType(block.forceGetType());
                        if (type != null) {
                            ConcurrentMap<Long, DynamicOwner> dynamicOwners = dynamics.get(type);
                            if (dynamicOwners != null) {
                                long id = block.getSingleValueLong();
                                DynamicOwner.Property owner = new DynamicOwner.Property(type, record);
                                DynamicOwner prev = dynamicOwners.put(id, owner);
                                if (prev != null) {
                                    engine.comparativeCheck(prev.record(records), owner);
                                }
                            }
                        }
                    }
                }
            }
            checker.check(record, engine, records);
        }
    };
}
Also used : RecordAccess(org.neo4j.consistency.store.RecordAccess) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) RelationshipGroupConsistencyReport(org.neo4j.consistency.report.ConsistencyReport.RelationshipGroupConsistencyReport) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) RecordType(org.neo4j.consistency.RecordType) OwningRecordCheck(org.neo4j.consistency.checking.OwningRecordCheck) RecordCheck(org.neo4j.consistency.checking.RecordCheck) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) CheckerEngine(org.neo4j.consistency.checking.CheckerEngine)

Example 4 with RecordAccess

use of org.neo4j.consistency.store.RecordAccess in project neo4j by neo4j.

the class NodeLabelReader method getListOfLabels.

public static <RECORD extends AbstractBaseRecord, REPORT extends ConsistencyReport> Set<Long> getListOfLabels(NodeRecord nodeRecord, RecordAccess records, CheckerEngine<RECORD, REPORT> engine) {
    final Set<Long> labels = new HashSet<>();
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(nodeRecord);
    if (nodeLabels instanceof DynamicNodeLabels) {
        DynamicNodeLabels dynamicNodeLabels = (DynamicNodeLabels) nodeLabels;
        long firstRecordId = dynamicNodeLabels.getFirstDynamicRecordId();
        RecordReference<DynamicRecord> firstRecordReference = records.nodeLabels(firstRecordId);
        engine.comparativeCheck(firstRecordReference, new LabelChainWalker<>(new LabelChainWalker.Validator<RECORD, REPORT>() {

            @Override
            public void onRecordNotInUse(DynamicRecord dynamicRecord, CheckerEngine<RECORD, REPORT> engine) {
            }

            @Override
            public void onRecordChainCycle(DynamicRecord record, CheckerEngine<RECORD, REPORT> engine) {
            }

            @Override
            public void onWellFormedChain(long[] labelIds, CheckerEngine<RECORD, REPORT> engine, RecordAccess records) {
                copyToSet(labelIds, labels);
            }
        }));
    } else {
        copyToSet(nodeLabels.get(null), labels);
    }
    return labels;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RecordAccess(org.neo4j.consistency.store.RecordAccess) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) CheckerEngine(org.neo4j.consistency.checking.CheckerEngine) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) InlineNodeLabels(org.neo4j.kernel.impl.store.InlineNodeLabels) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) HashSet(java.util.HashSet)

Example 5 with RecordAccess

use of org.neo4j.consistency.store.RecordAccess 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)

Aggregations

RecordAccess (org.neo4j.consistency.store.RecordAccess)5 Test (org.junit.Test)2 CheckerEngine (org.neo4j.consistency.checking.CheckerEngine)2 CacheAccess (org.neo4j.consistency.checking.cache.CacheAccess)2 DefaultCacheAccess (org.neo4j.consistency.checking.cache.DefaultCacheAccess)2 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)2 InconsistencyReport (org.neo4j.consistency.report.InconsistencyReport)2 HashSet (java.util.HashSet)1 RecordType (org.neo4j.consistency.RecordType)1 CheckDecorator (org.neo4j.consistency.checking.CheckDecorator)1 OwningRecordCheck (org.neo4j.consistency.checking.OwningRecordCheck)1 RecordCheck (org.neo4j.consistency.checking.RecordCheck)1 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)1 RelationshipGroupConsistencyReport (org.neo4j.consistency.report.ConsistencyReport.RelationshipGroupConsistencyReport)1 ConsistencyReporter (org.neo4j.consistency.report.ConsistencyReporter)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