コード例 #1
0
ファイル: FullCheck.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void execute(final org.neo4j.kernel.api.direct.DirectStoreAccess directStoreAccess, final org.neo4j.consistency.checking.CheckDecorator decorator, final org.neo4j.consistency.store.RecordAccess recordAccess, final org.neo4j.consistency.report.InconsistencyReport report, org.neo4j.consistency.checking.cache.CacheAccess cacheAccess, org.neo4j.consistency.report.ConsistencyReporter.Monitor reportMonitor) throws ConsistencyCheckIncompleteException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        internal virtual void Execute(DirectStoreAccess directStoreAccess, CheckDecorator decorator, RecordAccess recordAccess, InconsistencyReport report, CacheAccess cacheAccess, ConsistencyReporter.Monitor reportMonitor)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.consistency.report.ConsistencyReporter reporter = new org.neo4j.consistency.report.ConsistencyReporter(recordAccess, report, reportMonitor);
            ConsistencyReporter reporter          = new ConsistencyReporter(recordAccess, report, reportMonitor);
            StoreProcessor      processEverything = new StoreProcessor(decorator, reporter, Stage_Fields.SequentialForward, cacheAccess);

            ProgressMonitorFactory.MultiPartBuilder progress = _progressFactory.multipleParts("Full Consistency Check");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.store.StoreAccess nativeStores = directStoreAccess.nativeStores();
            StoreAccess nativeStores = directStoreAccess.NativeStores();

            try
            {
                using (IndexAccessors indexes = new IndexAccessors(directStoreAccess.Indexes(), nativeStores.SchemaStore, _samplingConfig))
                {
                    MultiPassStore.Factory multiPass   = new MultiPassStore.Factory(decorator, recordAccess, cacheAccess, report, reportMonitor);
                    ConsistencyCheckTasks  taskCreator = new ConsistencyCheckTasks(progress, processEverything, nativeStores, _statistics, cacheAccess, directStoreAccess.LabelScanStore(), indexes, directStoreAccess.TokenHolders(), multiPass, reporter, _threads);

                    if (_checkIndexStructure)
                    {
                        ConsistencyCheckIndexStructure(directStoreAccess.LabelScanStore(), indexes, reporter, _progressFactory);
                    }

                    IList <ConsistencyCheckerTask> tasks = taskCreator.CreateTasksForFullCheck(_checkLabelScanStore, _checkIndexes, _checkGraph);
                    progress.Build();
                    TaskExecutor.Execute(tasks, decorator.prepare);
                }
            }
            catch (Exception e)
            {
                throw new ConsistencyCheckIncompleteException(e);
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public void checkCounts(org.neo4j.kernel.impl.api.CountsAccessor counts, final org.neo4j.consistency.report.ConsistencyReporter reporter, org.neo4j.helpers.progress.ProgressMonitorFactory progressFactory)
        public virtual void CheckCounts(CountsAccessor counts, ConsistencyReporter reporter, ProgressMonitorFactory progressFactory)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int nodes = nodeCounts.size();
            int nodes = _nodeCounts.size();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int relationships = relationshipCounts.size();
            int relationships = _relationshipCounts.size();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int total = nodes + relationships;
            int total = nodes + relationships;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger nodeEntries = new java.util.concurrent.atomic.AtomicInteger(0);
            AtomicInteger nodeEntries = new AtomicInteger(0);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger relationshipEntries = new java.util.concurrent.atomic.AtomicInteger(0);
            AtomicInteger relationshipEntries = new AtomicInteger(0);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.helpers.progress.ProgressListener listener = progressFactory.singlePart("Checking node and relationship counts", total);
            ProgressListener listener = progressFactory.SinglePart("Checking node and relationship counts", total);

            listener.Started();
            Counts.accept(new CountsVisitor_AdapterAnonymousInnerClass(this, reporter, nodeEntries, relationshipEntries, listener));
            reporter.ForCounts(new CountsEntry(nodeKey(WILDCARD), nodeEntries.get()), CHECK_NODE_KEY_COUNT);
            reporter.ForCounts(new CountsEntry(relationshipKey(WILDCARD, WILDCARD, WILDCARD), relationshipEntries.get()), CHECK_RELATIONSHIP_KEY_COUNT);
            listener.Done();
        }
コード例 #3
0
 public PropertyAndNode2LabelIndexProcessor(ConsistencyReporter reporter, IndexAccessors indexes, PropertyReader propertyReader, CacheAccess cacheAccess, System.Func <NodeRecord, MandatoryProperties.Check <NodeRecord, ConsistencyReport_NodeConsistencyReport> > mandatoryProperties)
 {
     this._reporter            = reporter;
     this._cacheAccess         = cacheAccess;
     this._mandatoryProperties = mandatoryProperties;
     this._nodeIndexCheck      = new PropertyAndNodeIndexedCheck(indexes, propertyReader, cacheAccess);
     this._propertyCheck       = new PropertyRecordCheck();
 }
コード例 #4
0
 public CountsVisitor_AdapterAnonymousInnerClass(CountsBuilderDecorator outerInstance, ConsistencyReporter reporter, AtomicInteger nodeEntries, AtomicInteger relationshipEntries, ProgressListener listener)
 {
     this.outerInstance        = outerInstance;
     this._reporter            = reporter;
     this._nodeEntries         = nodeEntries;
     this._relationshipEntries = relationshipEntries;
     this._listener            = listener;
 }
コード例 #5
0
 internal RealCheck(RECORD record, Type reportClass, ConsistencyReporter reporter, RecordType recordType, MutableIntSet mandatoryKeys)
 {
     reportClass        = typeof(REPORT);
     this.Record        = record;
     this.ReportClass   = reportClass;
     this.Reporter      = reporter;
     this.RecordType    = recordType;
     this.MandatoryKeys = mandatoryKeys;
 }
コード例 #6
0
 internal ConsistencyCheckTasks(ProgressMonitorFactory.MultiPartBuilder multiPartBuilder, StoreProcessor defaultProcessor, StoreAccess nativeStores, Statistics statistics, CacheAccess cacheAccess, LabelScanStore labelScanStore, IndexAccessors indexes, TokenHolders tokenHolders, MultiPassStore.Factory multiPass, ConsistencyReporter reporter, int numberOfThreads)
 {
     this._multiPartBuilder = multiPartBuilder;
     this._defaultProcessor = defaultProcessor;
     this._nativeStores     = nativeStores;
     this._statistics       = statistics;
     this._cacheAccess      = cacheAccess;
     this._tokenHolders     = tokenHolders;
     this._multiPass        = multiPass;
     this._reporter         = reporter;
     this._labelScanStore   = labelScanStore;
     this._indexes          = indexes;
     this._numberOfThreads  = numberOfThreads;
 }
コード例 #7
0
ファイル: FullCheck.cs プロジェクト: Neo4Net/Neo4Net
        private static void ConsistencyCheckSchemaIndexes(IndexAccessors indexes, ConsistencyReporter report, ProgressListener listener)
        {
            IList <StoreIndexDescriptor> rulesToRemove = new List <StoreIndexDescriptor>();

            foreach (StoreIndexDescriptor onlineRule in indexes.OnlineRules())
            {
                ConsistencyReporter.FormattingDocumentedHandler handler = report.FormattingHandler(RecordType.INDEX);
                ReporterFactory reporterFactory = new ReporterFactory(handler);
                IndexAccessor   accessor        = indexes.AccessorFor(onlineRule);
                if (!accessor.ConsistencyCheck(reporterFactory))
                {
                    rulesToRemove.Add(onlineRule);
                }
                handler.UpdateSummary();
                listener.Add(1);
            }
            foreach (StoreIndexDescriptor toRemove in rulesToRemove)
            {
                indexes.Remove(toRemove);
            }
        }
コード例 #8
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public System.Func<org.neo4j.kernel.impl.store.record.NodeRecord,Check<org.neo4j.kernel.impl.store.record.NodeRecord,org.neo4j.consistency.report.ConsistencyReport_NodeConsistencyReport>> forNodes(final org.neo4j.consistency.report.ConsistencyReporter reporter)
        public virtual System.Func <NodeRecord, Check <NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> > ForNodes(ConsistencyReporter reporter)
        {
            return(node =>
            {
                MutableIntSet keys = null;
                foreach (long labelId in NodeLabelReader.GetListOfLabels(node, _storeAccess.NodeDynamicLabelStore))
                {
                    // labelId _is_ actually an int. A technical detail in the store format has these come in a long[]
                    int[] propertyKeys = _nodes.get(safeCastLongToInt(labelId));
                    if (propertyKeys != null)
                    {
                        if (keys == null)
                        {
                            keys = new IntHashSet(16);
                        }
                        foreach (int key in propertyKeys)
                        {
                            keys.add(key);
                        }
                    }
                }
                return keys != null ? new RealCheck <Org.Neo4j.Kernel.impl.store.record.NodeRecord, Check <Org.Neo4j.Kernel.impl.store.record.NodeRecord, Org.Neo4j.Consistency.report.ConsistencyReport_NodeConsistencyReport> >(node, typeof(ConsistencyReport.NodeConsistencyReport), reporter, RecordType.Node, keys) : MandatoryProperties.NoCheck();
            });
        }
コード例 #9
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public System.Func<org.neo4j.kernel.impl.store.record.RelationshipRecord,Check<org.neo4j.kernel.impl.store.record.RelationshipRecord,org.neo4j.consistency.report.ConsistencyReport_RelationshipConsistencyReport>> forRelationships(final org.neo4j.consistency.report.ConsistencyReporter reporter)
        public virtual System.Func <RelationshipRecord, Check <RelationshipRecord, Org.Neo4j.Consistency.report.ConsistencyReport_RelationshipConsistencyReport> > ForRelationships(ConsistencyReporter reporter)
        {
            return(relationship =>
            {
                int[] propertyKeys = _relationships.get(relationship.Type);
                if (propertyKeys != null)
                {
                    MutableIntSet keys = new IntHashSet(propertyKeys.Length);
                    foreach (int key in propertyKeys)
                    {
                        keys.add(key);
                    }
                    return new RealCheck <Org.Neo4j.Kernel.impl.store.record.RelationshipRecord, Check <Org.Neo4j.Kernel.impl.store.record.RelationshipRecord, Org.Neo4j.Consistency.report.ConsistencyReport_RelationshipConsistencyReport> >(relationship, typeof(ConsistencyReport.RelationshipConsistencyReport), reporter, RecordType.Relationship, keys);
                }
                return NoCheck();
            });
        }
コード例 #10
0
 internal RelationshipIndexProcessor(ConsistencyReporter reporter, IndexAccessors indexes, PropertyReader propertyReader, IList <StoreIndexDescriptor> relationshipIndexes)
 {
     this._reporter = reporter;
     _checker       = new RelationshipToIndexCheck(relationshipIndexes, indexes, propertyReader);
 }
コード例 #11
0
ファイル: FullCheck.cs プロジェクト: Neo4Net/Neo4Net
        private static void ConsistencyCheckLabelScanStore(LabelScanStore labelScanStore, ConsistencyReporter report, ProgressListener listener)
        {
            ConsistencyReporter.FormattingDocumentedHandler handler = report.FormattingHandler(RecordType.LABEL_SCAN_DOCUMENT);
            ReporterFactory proxyFactory = new ReporterFactory(handler);

            labelScanStore.ConsistencyCheck(proxyFactory);
            handler.UpdateSummary();
            listener.Add(1);
        }
コード例 #12
0
ファイル: FullCheck.cs プロジェクト: Neo4Net/Neo4Net
        private static void ConsistencyCheckIndexStructure(LabelScanStore labelScanStore, IndexAccessors indexes, ConsistencyReporter report, ProgressMonitorFactory progressMonitorFactory)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long schemaIndexCount = org.neo4j.helpers.collection.Iterables.count(indexes.onlineRules());
            long       schemaIndexCount = Iterables.count(indexes.OnlineRules());
            const long additionalCount  = 1;              // LabelScanStore
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long totalCount = schemaIndexCount + additionalCount;
            long totalCount = schemaIndexCount + additionalCount;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.helpers.progress.ProgressListener listener = progressMonitorFactory.singlePart("Index structure consistency check", totalCount);
            ProgressListener listener = progressMonitorFactory.SinglePart("Index structure consistency check", totalCount);

            listener.Started();

            ConsistencyCheckLabelScanStore(labelScanStore, report, listener);
            ConsistencyCheckSchemaIndexes(indexes, report, listener);

            listener.Done();
        }
コード例 #13
0
        public virtual IList <ConsistencyCheckerTask> CreateTasksForFullCheck(bool checkLabelScanStore, bool checkIndexes, bool checkGraph)
        {
            IList <ConsistencyCheckerTask> tasks = new List <ConsistencyCheckerTask>();

            if (checkGraph)
            {
                MandatoryProperties mandatoryProperties = new MandatoryProperties(_nativeStores);
                StoreProcessor      processor           = _multiPass.processor(CheckStage.Stage1NSPropsLabels, PROPERTIES);
                tasks.Add(Create(CheckStage.Stage1NSPropsLabels.name(), _nativeStores.NodeStore, processor, ROUND_ROBIN));
                //RelationshipStore pass - check label counts using cached labels, check properties, skip nodes and relationships
                processor = _multiPass.processor(CheckStage.Stage2RSLabels, LABELS);
                _multiPass.reDecorateRelationship(processor, RelationshipRecordCheck.relationshipRecordCheckForwardPass());
                tasks.Add(Create(CheckStage.Stage2RSLabels.name(), _nativeStores.RelationshipStore, processor, ROUND_ROBIN));
                //NodeStore pass - just cache nextRel and inUse
                tasks.Add(new CacheTask.CacheNextRel(CheckStage.Stage3NSNextRel, _cacheAccess, Scanner.scan(_nativeStores.NodeStore)));
                //RelationshipStore pass - check nodes inUse, FirstInFirst, FirstInSecond using cached info
                processor = _multiPass.processor(CheckStage.Stage4RSNextRel, NODES);
                _multiPass.reDecorateRelationship(processor, RelationshipRecordCheck.relationshipRecordCheckBackwardPass(new PropertyChain <>(mandatoryProperties.ForRelationships(_reporter))));
                tasks.Add(Create(CheckStage.Stage4RSNextRel.name(), _nativeStores.RelationshipStore, processor, ROUND_ROBIN));
                //NodeStore pass - just cache nextRel and inUse
                _multiPass.reDecorateNode(processor, NodeRecordCheck.toCheckNextRel(), true);
                _multiPass.reDecorateNode(processor, NodeRecordCheck.toCheckNextRelationshipGroup(), false);
                tasks.Add(new CacheTask.CheckNextRel(CheckStage.Stage5CheckNextRel, _cacheAccess, _nativeStores, processor));
                // source chain
                //RelationshipStore pass - forward scan of source chain using the cache.
                processor = _multiPass.processor(CheckStage.Stage6RSForward, RELATIONSHIPS);
                _multiPass.reDecorateRelationship(processor, RelationshipRecordCheck.relationshipRecordCheckSourceChain());
                tasks.Add(Create(CheckStage.Stage6RSForward.name(), _nativeStores.RelationshipStore, processor, QueueDistribution.RELATIONSHIPS));
                //RelationshipStore pass - reverse scan of source chain using the cache.
                processor = _multiPass.processor(CheckStage.Stage7RSBackward, RELATIONSHIPS);
                _multiPass.reDecorateRelationship(processor, RelationshipRecordCheck.relationshipRecordCheckSourceChain());
                tasks.Add(Create(CheckStage.Stage7RSBackward.name(), _nativeStores.RelationshipStore, processor, QueueDistribution.RELATIONSHIPS));

                //relationshipGroup
                StoreProcessor relGrpProcessor = _multiPass.processor(Stage_Fields.ParallelForward, RELATIONSHIP_GROUPS);
                tasks.Add(Create("RelationshipGroupStore-RelGrp", _nativeStores.RelationshipGroupStore, relGrpProcessor, ROUND_ROBIN));

                PropertyReader propertyReader = new PropertyReader(_nativeStores);
                tasks.Add(RecordScanner(CheckStage.Stage8PSProps.name(), new IterableStore <>(_nativeStores.NodeStore, true), new PropertyAndNode2LabelIndexProcessor(_reporter, checkIndexes ? _indexes : null, propertyReader, _cacheAccess, mandatoryProperties.ForNodes(_reporter)), CheckStage.Stage8PSProps, ROUND_ROBIN, new IterableStore <>(_nativeStores.PropertyStore, true)));

                // Checking that relationships are in their expected relationship indexes.
                IList <StoreIndexDescriptor> relationshipIndexes = Iterables.stream(_indexes.onlineRules()).filter(rule => rule.schema().entityType() == EntityType.RELATIONSHIP).collect(Collectors.toList());
                if (checkIndexes && relationshipIndexes.Count > 0)
                {
                    tasks.Add(RecordScanner(CheckStage.Stage9RSIndexes.name(), new IterableStore <>(_nativeStores.RelationshipStore, true), new RelationshipIndexProcessor(_reporter, _indexes, propertyReader, relationshipIndexes), CheckStage.Stage9RSIndexes, ROUND_ROBIN, new IterableStore <>(_nativeStores.PropertyStore, true)));
                }

                tasks.Add(Create("StringStore-Str", _nativeStores.StringStore, _multiPass.processor(Stage_Fields.SequentialForward, STRINGS), ROUND_ROBIN));
                tasks.Add(Create("ArrayStore-Arrays", _nativeStores.ArrayStore, _multiPass.processor(Stage_Fields.SequentialForward, ARRAYS), ROUND_ROBIN));
            }
            // The schema store is verified in multiple passes that share state since it fits into memory
            // and we care about the consistency of back references (cf. SemanticCheck)
            // PASS 1: Dynamic record chains
            tasks.Add(Create("SchemaStore", _nativeStores.SchemaStore, ROUND_ROBIN));
            // PASS 2: Rule integrity and obligation build up
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.consistency.checking.SchemaRecordCheck schemaCheck = new org.neo4j.consistency.checking.SchemaRecordCheck(new org.neo4j.kernel.impl.store.SchemaStorage(nativeStores.getSchemaStore()), indexes);
            SchemaRecordCheck schemaCheck = new SchemaRecordCheck(new SchemaStorage(_nativeStores.SchemaStore), _indexes);

            tasks.Add(new SchemaStoreProcessorTask <>("SchemaStoreProcessor-check_rules", _statistics, _numberOfThreads, _nativeStores.SchemaStore, _nativeStores, "check_rules", schemaCheck, _multiPartBuilder, _cacheAccess, _defaultProcessor, ROUND_ROBIN));
            // PASS 3: Obligation verification and semantic rule uniqueness
            tasks.Add(new SchemaStoreProcessorTask <>("SchemaStoreProcessor-check_obligations", _statistics, _numberOfThreads, _nativeStores.SchemaStore, _nativeStores, "check_obligations", schemaCheck.ForObligationChecking(), _multiPartBuilder, _cacheAccess, _defaultProcessor, ROUND_ROBIN));
            if (checkGraph)
            {
                tasks.Add(Create("RelationshipTypeTokenStore", _nativeStores.RelationshipTypeTokenStore, ROUND_ROBIN));
                tasks.Add(Create("PropertyKeyTokenStore", _nativeStores.PropertyKeyTokenStore, ROUND_ROBIN));
                tasks.Add(Create("LabelTokenStore", _nativeStores.LabelTokenStore, ROUND_ROBIN));
                tasks.Add(Create("RelationshipTypeNameStore", _nativeStores.RelationshipTypeNameStore, ROUND_ROBIN));
                tasks.Add(Create("PropertyKeyNameStore", _nativeStores.PropertyKeyNameStore, ROUND_ROBIN));
                tasks.Add(Create("LabelNameStore", _nativeStores.LabelNameStore, ROUND_ROBIN));
                tasks.Add(Create("NodeDynamicLabelStore", _nativeStores.NodeDynamicLabelStore, ROUND_ROBIN));
            }

            ConsistencyReporter filteredReporter = _multiPass.reporter(NODES);

            if (checkLabelScanStore)
            {
                long highId = _nativeStores.NodeStore.HighId;
                tasks.Add(new LabelIndexDirtyCheckTask(this));
                tasks.Add(RecordScanner("LabelScanStore", new GapFreeAllEntriesLabelScanReader(_labelScanStore.allNodeLabelRanges(), highId), new LabelScanDocumentProcessor(filteredReporter, new LabelScanCheck()), Stage_Fields.SequentialForward, ROUND_ROBIN));
            }
            if (checkIndexes)
            {
                tasks.Add(new IndexDirtyCheckTask(this));
                TokenNameLookup tokenNameLookup = new NonTransactionalTokenNameLookup(_tokenHolders, true);
                foreach (StoreIndexDescriptor indexRule in _indexes.onlineRules())
                {
                    tasks.Add(RecordScanner(format("Index_%d", indexRule.Id), new IndexIterator(_indexes.accessorFor(indexRule)), new IndexEntryProcessor(filteredReporter, new IndexCheck(indexRule), indexRule, tokenNameLookup), Stage_Fields.SequentialForward, ROUND_ROBIN));
                }
            }
            return(tasks);
        }