Search in sources :

Example 1 with InconsistencyMessageLogger

use of org.neo4j.consistency.report.InconsistencyMessageLogger 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 InconsistencyMessageLogger

use of org.neo4j.consistency.report.InconsistencyMessageLogger in project neo4j by neo4j.

the class InconsistencyReportReaderTest method shouldReadBasicEntities.

@Test
public void shouldReadBasicEntities() throws Exception {
    // GIVEN
    ByteArrayOutputStream out = new ByteArrayOutputStream(1_000);
    FormattedLog log = FormattedLog.toOutputStream(out);
    InconsistencyMessageLogger logger = new InconsistencyMessageLogger(log);
    long nodeId = 5;
    long relationshipGroupId = 10;
    long relationshipId = 15;
    long propertyId = 20;
    logger.error(RecordType.NODE, new NodeRecord(nodeId), "Some error", "something");
    logger.error(RecordType.RELATIONSHIP, new RelationshipRecord(relationshipId), "Some error", "something");
    logger.error(RecordType.RELATIONSHIP_GROUP, new RelationshipGroupRecord(relationshipGroupId), "Some error", "something");
    logger.error(RecordType.PROPERTY, new PropertyRecord(propertyId), "Some error", "something");
    String text = out.toString();
    PrimitiveLongSet nodes = Primitive.longSet();
    PrimitiveLongSet relationships = Primitive.longSet();
    PrimitiveLongSet relationshipGroups = Primitive.longSet();
    PrimitiveLongSet properties = Primitive.longSet();
    // WHEN
    InconsistencyReportReader reader = new InconsistencyReportReader(new Inconsistencies() {

        @Override
        public void relationshipGroup(long id) {
            relationshipGroups.add(id);
        }

        @Override
        public void relationship(long id) {
            relationships.add(id);
        }

        @Override
        public void property(long id) {
            properties.add(id);
        }

        @Override
        public void node(long id) {
            nodes.add(id);
        }
    });
    reader.read(new StringReader(text));
    // THEN
    assertEquals(asSet(iterator(nodeId)), nodes);
    assertEquals(asSet(iterator(relationshipId)), relationships);
    assertEquals(asSet(iterator(relationshipGroupId)), relationshipGroups);
    assertEquals(asSet(iterator(propertyId)), properties);
}
Also used : FormattedLog(org.neo4j.logging.FormattedLog) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Inconsistencies(org.neo4j.tools.dump.InconsistencyReportReader.Inconsistencies) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PrimitiveLongSet(org.neo4j.collection.primitive.PrimitiveLongSet) StringReader(java.io.StringReader) InconsistencyMessageLogger(org.neo4j.consistency.report.InconsistencyMessageLogger) Test(org.junit.Test)

Aggregations

InconsistencyMessageLogger (org.neo4j.consistency.report.InconsistencyMessageLogger)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 StringReader (java.io.StringReader)1 Test (org.junit.Test)1 PrimitiveLongSet (org.neo4j.collection.primitive.PrimitiveLongSet)1 CheckDecorator (org.neo4j.consistency.checking.CheckDecorator)1 CacheAccess (org.neo4j.consistency.checking.cache.CacheAccess)1 DefaultCacheAccess (org.neo4j.consistency.checking.cache.DefaultCacheAccess)1 ConsistencyReporter (org.neo4j.consistency.report.ConsistencyReporter)1 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)1 InconsistencyReport (org.neo4j.consistency.report.InconsistencyReport)1 CacheSmallStoresRecordAccess (org.neo4j.consistency.store.CacheSmallStoresRecordAccess)1 DirectRecordAccess (org.neo4j.consistency.store.DirectRecordAccess)1 RecordAccess (org.neo4j.consistency.store.RecordAccess)1 CountsAccessor (org.neo4j.kernel.impl.api.CountsAccessor)1 CountsTracker (org.neo4j.kernel.impl.store.counts.CountsTracker)1 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)1 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)1 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)1 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)1