コード例 #1
0
ファイル: GraphStoreFixture.cs プロジェクト: Neo4Net/Neo4Net
        private DirectStoreAccess DirectStoreAccess(bool readOnly)
        {
            if (_directStoreAccess == null)
            {
                _life.start();
                JobScheduler scheduler = _life.add(JobSchedulerFactory.createInitialisedScheduler());
                _fileSystem = new DefaultFileSystemAbstraction();
                PageCache   pageCache   = GetPageCache(_fileSystem);
                LogProvider logProvider = NullLogProvider.Instance;
                Config      config      = Config.defaults(GraphDatabaseSettings.read_only, readOnly ? TRUE : FALSE);
                DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(_fileSystem);
                StoreFactory storeFactory = new StoreFactory(_directory.databaseLayout(), config, idGeneratorFactory, pageCache, _fileSystem, logProvider, EmptyVersionContextSupplier.EMPTY);
                _neoStore = storeFactory.OpenAllNeoStores();
                StoreAccess nativeStores;
                if (_keepStatistics)
                {
                    AccessStatistics accessStatistics = new AccessStatistics();
                    _statistics  = new VerboseStatistics(accessStatistics, new DefaultCounts(defaultConsistencyCheckThreadsNumber()), NullLog.Instance);
                    nativeStores = new AccessStatsKeepingStoreAccess(_neoStore, accessStatistics);
                }
                else
                {
                    _statistics  = Statistics.NONE;
                    nativeStores = new StoreAccess(_neoStore);
                }
                nativeStores.Initialize();

                IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, nativeStores.RawNeoStores);

                Monitors         monitors       = new Monitors();
                LabelScanStore   labelScanStore = StartLabelScanStore(pageCache, indexStoreView, monitors, readOnly);
                IndexProviderMap indexes        = CreateIndexes(pageCache, _fileSystem, _directory.databaseDir(), config, scheduler, logProvider, monitors);
                TokenHolders     tokenHolders   = new TokenHolders(new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_LABEL), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_RELATIONSHIP_TYPE));
                tokenHolders.PropertyKeyTokens().InitialTokens      = _neoStore.PropertyKeyTokenStore.Tokens;
                tokenHolders.LabelTokens().InitialTokens            = _neoStore.LabelTokenStore.Tokens;
                tokenHolders.RelationshipTypeTokens().InitialTokens = _neoStore.RelationshipTypeTokenStore.Tokens;
                _directStoreAccess = new DirectStoreAccess(nativeStores, labelScanStore, indexes, tokenHolders);
            }
            return(_directStoreAccess);
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Result runFullConsistencyCheck(org.neo4j.io.layout.DatabaseLayout databaseLayout, org.neo4j.kernel.configuration.Config config, org.neo4j.helpers.progress.ProgressMonitorFactory progressFactory, final org.neo4j.logging.LogProvider logProvider, final org.neo4j.io.fs.FileSystemAbstraction fileSystem, final org.neo4j.io.pagecache.PageCache pageCache, final boolean verbose, java.io.File reportDir, org.neo4j.consistency.checking.full.ConsistencyFlags consistencyFlags) throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public virtual Result RunFullConsistencyCheck(DatabaseLayout databaseLayout, Config config, ProgressMonitorFactory progressFactory, LogProvider logProvider, FileSystemAbstraction fileSystem, PageCache pageCache, bool verbose, File reportDir, ConsistencyFlags consistencyFlags)
        {
            AssertRecovered(databaseLayout, config, fileSystem, pageCache);
            Log log = logProvider.getLog(this.GetType());

            config.augment(GraphDatabaseSettings.read_only, TRUE);
            config.augment(GraphDatabaseSettings.pagecache_warmup_enabled, FALSE);

            StoreFactory factory = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fileSystem), pageCache, fileSystem, logProvider, EmptyVersionContextSupplier.EMPTY);

            ConsistencySummaryStatistics summary;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File reportFile = chooseReportPath(reportDir);
            File reportFile = ChooseReportPath(reportDir);

            Suppliers.Lazy <PrintWriter> reportWriterSupplier = GetReportWriterSupplier(fileSystem, reportFile);
            Log reportLog = new ConsistencyReportLog(reportWriterSupplier);

            // Bootstrap kernel extensions
            Monitors                 monitors     = new Monitors();
            LifeSupport              life         = new LifeSupport();
            JobScheduler             jobScheduler = life.Add(JobSchedulerFactory.createInitialisedScheduler());
            TokenHolders             tokenHolders = new TokenHolders(new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_LABEL), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_RELATIONSHIP_TYPE));
            DatabaseKernelExtensions extensions   = life.Add(instantiateKernelExtensions(databaseLayout.DatabaseDirectory(), fileSystem, config, new SimpleLogService(logProvider, logProvider), pageCache, jobScheduler, RecoveryCleanupWorkCollector.ignore(), TOOL, monitors, tokenHolders));
            DefaultIndexProviderMap  indexes      = life.Add(new DefaultIndexProviderMap(extensions, config));

            try
            {
                using (NeoStores neoStores = factory.OpenAllNeoStores())
                {
                    // Load tokens before starting extensions, etc.
                    tokenHolders.PropertyKeyTokens().InitialTokens      = neoStores.PropertyKeyTokenStore.Tokens;
                    tokenHolders.LabelTokens().InitialTokens            = neoStores.LabelTokenStore.Tokens;
                    tokenHolders.RelationshipTypeTokens().InitialTokens = neoStores.RelationshipTypeTokenStore.Tokens;

                    life.Start();

                    LabelScanStore labelScanStore = new NativeLabelScanStore(pageCache, databaseLayout, fileSystem, Org.Neo4j.Kernel.Impl.Api.scan.FullStoreChangeStream_Fields.Empty, true, monitors, RecoveryCleanupWorkCollector.ignore());
                    life.Add(labelScanStore);

                    int              numberOfThreads = DefaultConsistencyCheckThreadsNumber();
                    Statistics       statistics;
                    StoreAccess      storeAccess;
                    AccessStatistics stats = new AccessStatistics();
                    if (verbose)
                    {
                        statistics  = new VerboseStatistics(stats, new DefaultCounts(numberOfThreads), log);
                        storeAccess = new AccessStatsKeepingStoreAccess(neoStores, stats);
                    }
                    else
                    {
                        statistics  = Statistics.NONE;
                        storeAccess = new StoreAccess(neoStores);
                    }
                    storeAccess.Initialize();
                    DirectStoreAccess stores = new DirectStoreAccess(storeAccess, labelScanStore, indexes, tokenHolders);
                    FullCheck         check  = new FullCheck(progressFactory, statistics, numberOfThreads, consistencyFlags, config, true);
                    summary = check.Execute(stores, new DuplicatingLog(log, reportLog));
                }
            }
            finally
            {
                life.Shutdown();
                if (reportWriterSupplier.Initialised)
                {
                    reportWriterSupplier.get().close();
                }
            }

            if (!summary.Consistent)
            {
                log.Warn("See '%s' for a detailed consistency report.", reportFile.Path);
                return(Result.failure(reportFile));
            }
            return(Result.success(reportFile));
        }