コード例 #1
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, org.neo4j.logging.LogProvider logProvider, org.neo4j.io.fs.FileSystemAbstraction fileSystem, boolean verbose, java.io.File reportDir, org.neo4j.consistency.checking.full.ConsistencyFlags consistencyFlags) throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
        public virtual Result RunFullConsistencyCheck(DatabaseLayout databaseLayout, Config config, ProgressMonitorFactory progressFactory, LogProvider logProvider, FileSystemAbstraction fileSystem, bool verbose, File reportDir, ConsistencyFlags consistencyFlags)
        {
            Log          log          = logProvider.getLog(this.GetType());
            JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler();
            ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, logProvider.GetLog(typeof(PageCache)), EmptyVersionContextSupplier.EMPTY, jobScheduler);
            PageCache pageCache = pageCacheFactory.OrCreatePageCache;

            try
            {
                return(RunFullConsistencyCheck(databaseLayout, config, progressFactory, logProvider, fileSystem, pageCache, verbose, reportDir, consistencyFlags));
            }
            finally
            {
                try
                {
                    pageCache.Close();
                }
                catch (Exception e)
                {
                    log.Error("Failure during shutdown of the page cache", e);
                }
                try
                {
                    jobScheduler.close();
                }
                catch (Exception e)
                {
                    log.Error("Failure during shutdown of the job scheduler", e);
                }
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void run(final org.neo4j.io.fs.FileSystemAbstraction fs, final java.io.File storeDirectory, org.neo4j.kernel.configuration.Config config, org.neo4j.logging.LogProvider userLogProvider) throws Exception
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public static void Run(FileSystemAbstraction fs, File storeDirectory, Config config, LogProvider userLogProvider)
        {
            StoreLogService logService = StoreLogService.withUserLogProvider(userLogProvider).withInternalLog(config.Get(store_internal_log_path)).build(fs);

            VisibleMigrationProgressMonitor progressMonitor = new VisibleMigrationProgressMonitor(logService.GetUserLog(typeof(StoreMigration)));

            LifeSupport life = new LifeSupport();

            life.Add(logService);

            // Add participants from kernel extensions...
            DefaultExplicitIndexProvider migrationIndexProvider = new DefaultExplicitIndexProvider();

            Log          log          = userLogProvider.GetLog(typeof(StoreMigration));
            JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler();

            try
            {
                using (PageCache pageCache = createPageCache(fs, config, jobScheduler))
                {
                    Dependencies deps     = new Dependencies();
                    Monitors     monitors = new Monitors();
                    deps.SatisfyDependencies(fs, config, migrationIndexProvider, pageCache, logService, monitors, RecoveryCleanupWorkCollector.immediate());

                    KernelContext            kernelContext    = new SimpleKernelContext(storeDirectory, DatabaseInfo.UNKNOWN, deps);
                    DatabaseKernelExtensions kernelExtensions = life.Add(new DatabaseKernelExtensions(kernelContext, GraphDatabaseDependencies.newDependencies().kernelExtensions(), deps, ignore()));

                    DatabaseLayout databaseLayout = DatabaseLayout.of(storeDirectory);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles = org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.activeFilesBuilder(databaseLayout, fs, pageCache).withConfig(config).build();
                    LogFiles       logFiles    = LogFilesBuilder.activeFilesBuilder(databaseLayout, fs, pageCache).withConfig(config).build();
                    LogTailScanner tailScanner = new LogTailScanner(logFiles, new VersionAwareLogEntryReader <Org.Neo4j.Kernel.impl.transaction.log.ReadableClosablePositionAwareChannel>(), monitors);

                    DefaultIndexProviderMap indexProviderMap = life.Add(new DefaultIndexProviderMap(kernelExtensions, config));

                    // Add the kernel store migrator
                    life.Start();

                    long             startTime = DateTimeHelper.CurrentUnixTimeMillis();
                    DatabaseMigrator migrator  = new DatabaseMigrator(progressMonitor, fs, config, logService, indexProviderMap, migrationIndexProvider, pageCache, RecordFormatSelector.selectForConfig(config, userLogProvider), tailScanner, jobScheduler);
                    migrator.Migrate(databaseLayout);

                    // Append checkpoint so the last log entry will have the latest version
                    AppendCheckpoint(logFiles, tailScanner);

                    long duration = DateTimeHelper.CurrentUnixTimeMillis() - startTime;
                    log.Info(format("Migration completed in %d s%n", duration / 1000));
                }
            }
            catch (Exception e)
            {
                throw new StoreUpgrader.UnableToUpgradeException("Failure during upgrade", e);
            }
            finally
            {
                life.Shutdown();
                jobScheduler.close();
            }
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 120_000) public void shouldBeAbleToStartAndStoreWithoutSuccessfulJoin()
        public virtual void ShouldBeAbleToStartAndStoreWithoutSuccessfulJoin()
        {
            // given
            IDictionary <string, string> @params = stringMap();

            SslPolicyConfig policyConfig = new SslPolicyConfig("default");

            @params[neo4j_home.name()] = _home.AbsolutePath;
            @params[policyConfig.BaseDirectory.name()] = "certificates/default";

            JobScheduler          jobScheduler   = JobSchedulerFactory.createInitialisedScheduler();
            PlatformModule        platformModule = new PlatformModule(TestDirectory.storeDir(), Config.defaults(), ENTERPRISE, newDependencies());
            AbstractEditionModule editionModule  = new EnterpriseEditionModule(platformModule);
            // Random members that does not exists, discovery will never succeed
            string initialHosts = "localhost:" + PortAuthority.allocatePort() + ",localhost:" + PortAuthority.allocatePort();
            Config config       = config();

            config.augment(initial_discovery_members, initialHosts);

            // Setup SslPolicy
            config.augment(neo4j_home.name(), _home.AbsolutePath);
            config.Augment(policyConfig.BaseDirectory.name(), "certificates/default");

            SslPolicyLoader sslPolicyLoader = SslPolicyLoader.create(config, NullLogProvider.Instance);

            RemoteMembersResolver remoteMembersResolver = ResolutionResolverFactory.ChooseResolver(config, platformModule.Logging);

            // then
            SslPolicy sslPolicy = sslPolicyLoader.GetPolicy("default");
            Monitors  monitors  = new Monitors();
            SecureHazelcastCoreTopologyService service = new SecureHazelcastCoreTopologyService(config, sslPolicy, new MemberId(System.Guid.randomUUID()), jobScheduler, NullLogProvider.Instance, NullLogProvider.Instance, remoteMembersResolver, new TopologyServiceNoRetriesStrategy(), monitors);

            try
            {
                service.Init();
                service.Start();
                service.Stop();
            }
            catch (Exception)
            {
                fail("Caught an Exception");
            }
        }
コード例 #4
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);
        }
コード例 #5
0
 protected internal virtual JobScheduler CreateJobScheduler()
 {
     return(JobSchedulerFactory.createInitialisedScheduler());
 }
コード例 #6
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));
        }