コード例 #1
0
        private void EditionInvariants(PlatformModule platformModule, Dependencies dependencies, Config config, LogService logging, LifeSupport life)
        {
            StatementLocksFactoryProviderConflict = locks => (new StatementLocksFactorySelector(locks, config, logging)).select();

            dependencies.SatisfyDependency(CreateKernelData(platformModule.FileSystem, platformModule.PageCache, platformModule.StoreLayout.storeDirectory(), config, platformModule.DataSourceManager, life));

            IoLimiterConflict = new ConfigurableIOLimiter(platformModule.Config);

            HeaderInformationFactoryConflict = CreateHeaderInformationFactory();

            SchemaWriteGuardConflict = CreateSchemaWriteGuard();

            TransactionStartTimeoutConflict = config.Get(GraphDatabaseSettings.transaction_start_timeout).toMillis();

            ConstraintSemanticsConflict = new EnterpriseConstraintSemantics();

            PublishEditionInfo(dependencies.ResolveDependency(typeof(UsageData)), platformModule.DatabaseInfo, config);

            ConnectionTrackerConflict = dependencies.SatisfyDependency(CreateConnectionTracker());
        }
コード例 #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 EnterpriseReadReplicaEditionModule(final org.neo4j.graphdb.factory.module.PlatformModule platformModule, final org.neo4j.causalclustering.discovery.DiscoveryServiceFactory discoveryServiceFactory, org.neo4j.causalclustering.identity.MemberId myself)
        public EnterpriseReadReplicaEditionModule(PlatformModule platformModule, DiscoveryServiceFactory discoveryServiceFactory, MemberId myself)
        {
            LogService logging = platformModule.Logging;

            IoLimiterConflict = new ConfigurableIOLimiter(platformModule.Config);
            platformModule.JobScheduler.TopLevelGroupName = "ReadReplica " + myself;

            Dependencies          dependencies = platformModule.Dependencies;
            Config                config       = platformModule.Config;
            FileSystemAbstraction fileSystem   = platformModule.FileSystem;
            PageCache             pageCache    = platformModule.PageCache;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.layout.DatabaseLayout databaseLayout = platformModule.storeLayout.databaseLayout(config.get(org.neo4j.graphdb.factory.GraphDatabaseSettings.active_database));
            DatabaseLayout databaseLayout = platformModule.StoreLayout.databaseLayout(config.Get(GraphDatabaseSettings.active_database));

            LifeSupport life = platformModule.Life;

            ThreadToTransactionBridgeConflict = dependencies.SatisfyDependency(new ThreadToStatementContextBridge(GetGlobalAvailabilityGuard(platformModule.Clock, logging, platformModule.Config)));
            this.AccessCapabilityConflict     = new ReadOnly();

            WatcherServiceFactoryConflict = dir => CreateFileSystemWatcherService(fileSystem, dir, logging, platformModule.JobScheduler, config, FileWatcherFileNameFilter());
            dependencies.SatisfyDependencies(WatcherServiceFactoryConflict);

            ReadReplicaLockManager emptyLockManager = new ReadReplicaLockManager();

            LocksSupplierConflict = () => emptyLockManager;
            StatementLocksFactoryProviderConflict = locks => (new StatementLocksFactorySelector(locks, config, logging)).select();

            IdContextFactoryConflict = IdContextFactoryBuilder.of(new EnterpriseIdTypeConfigurationProvider(config), platformModule.JobScheduler).withFileSystem(fileSystem).build();

            TokenHoldersProviderConflict = databaseName => 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));

            File contextDirectory = platformModule.StoreLayout.storeDirectory();

            life.Add(dependencies.SatisfyDependency(new KernelData(fileSystem, pageCache, contextDirectory, config, platformModule.DataSourceManager)));

            HeaderInformationFactoryConflict = TransactionHeaderInformationFactory.DEFAULT;

            SchemaWriteGuardConflict = () =>
            {
            };

            TransactionStartTimeoutConflict = config.Get(GraphDatabaseSettings.transaction_start_timeout).toMillis();

            ConstraintSemanticsConflict = new EnterpriseConstraintSemantics();

            PublishEditionInfo(dependencies.ResolveDependency(typeof(UsageData)), platformModule.DatabaseInfo, config);
            CommitProcessFactoryConflict = ReadOnly();

            ConnectionTrackerConflict = dependencies.SatisfyDependency(CreateConnectionTracker());

            _logProvider = platformModule.Logging.InternalLogProvider;
            LogProvider userLogProvider = platformModule.Logging.UserLogProvider;

            _logProvider.getLog(this.GetType()).info(string.Format("Generated new id: {0}", myself));

            RemoteMembersResolver hostnameResolver = chooseResolver(config, platformModule.Logging);

            ConfigureDiscoveryService(discoveryServiceFactory, dependencies, config, _logProvider);

            _topologyService = discoveryServiceFactory.ReadReplicaTopologyService(config, _logProvider, platformModule.JobScheduler, myself, hostnameResolver, ResolveStrategy(config, _logProvider));

            life.Add(dependencies.SatisfyDependency(_topologyService));

            // We need to satisfy the dependency here to keep users of it, such as BoltKernelExtension, happy.
            dependencies.SatisfyDependency(SslPolicyLoader.create(config, _logProvider));

            DuplexPipelineWrapperFactory pipelineWrapperFactory = pipelineWrapperFactory();
            PipelineWrapper serverPipelineWrapper       = pipelineWrapperFactory.ForServer(config, dependencies, _logProvider, CausalClusteringSettings.ssl_policy);
            PipelineWrapper clientPipelineWrapper       = pipelineWrapperFactory.ForClient(config, dependencies, _logProvider, CausalClusteringSettings.ssl_policy);
            PipelineWrapper backupServerPipelineWrapper = pipelineWrapperFactory.ForServer(config, dependencies, _logProvider, OnlineBackupSettings.ssl_policy);

            NettyPipelineBuilderFactory clientPipelineBuilderFactory       = new NettyPipelineBuilderFactory(clientPipelineWrapper);
            NettyPipelineBuilderFactory serverPipelineBuilderFactory       = new NettyPipelineBuilderFactory(serverPipelineWrapper);
            NettyPipelineBuilderFactory backupServerPipelineBuilderFactory = new NettyPipelineBuilderFactory(backupServerPipelineWrapper);

            SupportedProtocolCreator                 supportedProtocolCreator   = new SupportedProtocolCreator(config, _logProvider);
            ApplicationSupportedProtocols            supportedCatchupProtocols  = supportedProtocolCreator.CreateSupportedCatchupProtocol();
            ICollection <ModifierSupportedProtocols> supportedModifierProtocols = supportedProtocolCreator.CreateSupportedModifierProtocols();

            ApplicationProtocolRepository applicationProtocolRepository = new ApplicationProtocolRepository(Protocol_ApplicationProtocols.values(), supportedCatchupProtocols);
            ModifierProtocolRepository    modifierProtocolRepository    = new ModifierProtocolRepository(Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocols.values(), supportedModifierProtocols);

            System.Func <CatchUpResponseHandler, ChannelInitializer <SocketChannel> > channelInitializer = handler =>
            {
                ProtocolInstallerRepository <ProtocolInstaller.Orientation.Client> protocolInstallerRepository = new ProtocolInstallerRepository <ProtocolInstaller.Orientation.Client>(singletonList(new CatchupProtocolClientInstaller.Factory(clientPipelineBuilderFactory, _logProvider, handler)), ModifierProtocolInstaller.allClientInstallers);
                Duration handshakeTimeout = config.Get(CausalClusteringSettings.handshake_timeout);
                return(new HandshakeClientInitializer(applicationProtocolRepository, modifierProtocolRepository, protocolInstallerRepository, clientPipelineBuilderFactory, handshakeTimeout, _logProvider, userLogProvider));
            };

            long inactivityTimeoutMs = config.Get(CausalClusteringSettings.catch_up_client_inactivity_timeout).toMillis();

            CatchUpClient catchUpClient = life.Add(new CatchUpClient(_logProvider, Clocks.systemClock(), inactivityTimeoutMs, channelInitializer));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final System.Func<org.neo4j.kernel.internal.DatabaseHealth> databaseHealthSupplier = () -> platformModule.dataSourceManager.getDataSource().getDependencyResolver().resolveDependency(org.neo4j.kernel.internal.DatabaseHealth.class);
            System.Func <DatabaseHealth> databaseHealthSupplier = () => platformModule.DataSourceManager.DataSource.DependencyResolver.resolveDependency(typeof(DatabaseHealth));

            StoreFiles storeFiles = new StoreFiles(fileSystem, pageCache);
            LogFiles   logFiles   = BuildLocalDatabaseLogFiles(platformModule, fileSystem, databaseLayout, config);

            LocalDatabase localDatabase = new LocalDatabase(databaseLayout, storeFiles, logFiles, platformModule.DataSourceManager, databaseHealthSupplier, GetGlobalAvailabilityGuard(platformModule.Clock, platformModule.Logging, platformModule.Config), _logProvider);

            System.Func <TransactionCommitProcess> writableCommitProcess = () => new TransactionRepresentationCommitProcess(localDatabase.DataSource().DependencyResolver.resolveDependency(typeof(TransactionAppender)), localDatabase.DataSource().DependencyResolver.resolveDependency(typeof(StorageEngine)));

            LifeSupport txPulling    = new LifeSupport();
            int         maxBatchSize = config.Get(CausalClusteringSettings.read_replica_transaction_applier_batch_size);

            CommandIndexTracker commandIndexTracker = platformModule.Dependencies.satisfyDependency(new CommandIndexTracker());
            BatchingTxApplier   batchingTxApplier   = new BatchingTxApplier(maxBatchSize, () => localDatabase.DataSource().DependencyResolver.resolveDependency(typeof(TransactionIdStore)), writableCommitProcess, platformModule.Monitors, platformModule.Tracers.pageCursorTracerSupplier, platformModule.VersionContextSupplier, commandIndexTracker, _logProvider);

            TimerService timerService = new TimerService(platformModule.JobScheduler, _logProvider);

            ExponentialBackoffStrategy storeCopyBackoffStrategy = new ExponentialBackoffStrategy(1, config.Get(CausalClusteringSettings.store_copy_backoff_max_wait).toMillis(), TimeUnit.MILLISECONDS);

            RemoteStore remoteStore = new RemoteStore(platformModule.Logging.InternalLogProvider, fileSystem, platformModule.PageCache, new StoreCopyClient(catchUpClient, platformModule.Monitors, _logProvider, storeCopyBackoffStrategy), new TxPullClient(catchUpClient, platformModule.Monitors), new TransactionLogCatchUpFactory(), config, platformModule.Monitors);

            CopiedStoreRecovery copiedStoreRecovery = new CopiedStoreRecovery(config, platformModule.KernelExtensionFactories, platformModule.PageCache);

            txPulling.Add(copiedStoreRecovery);

            CompositeSuspendable servicesToStopOnStoreCopy = new CompositeSuspendable();

            StoreCopyProcess storeCopyProcess = new StoreCopyProcess(fileSystem, pageCache, localDatabase, copiedStoreRecovery, remoteStore, _logProvider);

            ConnectToRandomCoreServerStrategy defaultStrategy = new ConnectToRandomCoreServerStrategy();

            defaultStrategy.Inject(_topologyService, config, _logProvider, myself);

            UpstreamDatabaseStrategySelector upstreamDatabaseStrategySelector = CreateUpstreamDatabaseStrategySelector(myself, config, _logProvider, _topologyService, defaultStrategy);

            CatchupPollingProcess catchupProcess = new CatchupPollingProcess(_logProvider, localDatabase, servicesToStopOnStoreCopy, catchUpClient, upstreamDatabaseStrategySelector, timerService, config.Get(CausalClusteringSettings.pull_interval).toMillis(), batchingTxApplier, platformModule.Monitors, storeCopyProcess, databaseHealthSupplier, _topologyService);

            dependencies.SatisfyDependencies(catchupProcess);

            txPulling.Add(batchingTxApplier);
            txPulling.Add(catchupProcess);
            txPulling.Add(new WaitForUpToDateStore(catchupProcess, _logProvider));

            ExponentialBackoffStrategy retryStrategy = new ExponentialBackoffStrategy(1, 30, TimeUnit.SECONDS);

            life.Add(new ReadReplicaStartupProcess(remoteStore, localDatabase, txPulling, upstreamDatabaseStrategySelector, retryStrategy, _logProvider, platformModule.Logging.UserLogProvider, storeCopyProcess, _topologyService));

            CheckPointerService         checkPointerService  = new CheckPointerService(() => localDatabase.DataSource().DependencyResolver.resolveDependency(typeof(CheckPointer)), platformModule.JobScheduler, Group.CHECKPOINT);
            RegularCatchupServerHandler catchupServerHandler = new RegularCatchupServerHandler(platformModule.Monitors, _logProvider, localDatabase.storeId, localDatabase.dataSource, localDatabase.isAvailable, fileSystem, null, checkPointerService);

            InstalledProtocolHandler installedProtocolHandler = new InstalledProtocolHandler();               // TODO: hook into a procedure
            Server catchupServer = (new CatchupServerBuilder(catchupServerHandler)).serverHandler(installedProtocolHandler).catchupProtocols(supportedCatchupProtocols).modifierProtocols(supportedModifierProtocols).pipelineBuilder(serverPipelineBuilderFactory).userLogProvider(userLogProvider).debugLogProvider(_logProvider).listenAddress(config.Get(transaction_listen_address)).serverName("catchup-server").build();

            TransactionBackupServiceProvider transactionBackupServiceProvider = new TransactionBackupServiceProvider(_logProvider, userLogProvider, supportedCatchupProtocols, supportedModifierProtocols, backupServerPipelineBuilderFactory, catchupServerHandler, installedProtocolHandler);
            Optional <Server> backupCatchupServer = transactionBackupServiceProvider.ResolveIfBackupEnabled(config);

            servicesToStopOnStoreCopy.Add(catchupServer);
            backupCatchupServer.ifPresent(servicesToStopOnStoreCopy.add);

            life.Add(catchupServer);                 // must start last and stop first, since it handles external requests
            backupCatchupServer.ifPresent(life.add);
        }