Exemple #1
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 ConsensusModule(org.neo4j.causalclustering.identity.MemberId myself, final org.neo4j.graphdb.factory.module.PlatformModule platformModule, org.neo4j.causalclustering.messaging.Outbound<org.neo4j.causalclustering.identity.MemberId,RaftMessages_RaftMessage> outbound, java.io.File clusterStateDirectory, org.neo4j.causalclustering.discovery.CoreTopologyService coreTopologyService)
        public ConsensusModule(MemberId myself, PlatformModule platformModule, Outbound <MemberId, RaftMessages_RaftMessage> outbound, File clusterStateDirectory, CoreTopologyService coreTopologyService)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.configuration.Config config = platformModule.config;
            Config config = platformModule.Config;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.logging.internal.LogService logging = platformModule.logging;
            LogService logging = platformModule.Logging;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.fs.FileSystemAbstraction fileSystem = platformModule.fileSystem;
            FileSystemAbstraction fileSystem = platformModule.FileSystem;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.lifecycle.LifeSupport life = platformModule.life;
            LifeSupport life = platformModule.Life;

            LogProvider logProvider = logging.InternalLogProvider;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.core.state.storage.SafeChannelMarshal<org.neo4j.causalclustering.core.replication.ReplicatedContent> marshal = org.neo4j.causalclustering.messaging.marshalling.CoreReplicatedContentMarshal.marshaller();
            SafeChannelMarshal <ReplicatedContent> marshal = CoreReplicatedContentMarshal.marshaller();

            RaftLog underlyingLog = CreateRaftLog(config, life, fileSystem, clusterStateDirectory, marshal, logProvider, platformModule.JobScheduler);

            _raftLog = new MonitoredRaftLog(underlyingLog, platformModule.Monitors);

            StateStorage <TermState>           termState;
            StateStorage <VoteState>           voteState;
            StateStorage <RaftMembershipState> raftMembershipStorage;

            StateStorage <TermState> durableTermState = life.Add(new DurableStateStorage <TermState>(fileSystem, clusterStateDirectory, RAFT_TERM_NAME, new TermState.Marshal(), config.Get(CausalClusteringSettings.term_state_size), logProvider));

            termState = new MonitoredTermStateStorage(durableTermState, platformModule.Monitors);

            voteState = life.Add(new DurableStateStorage <>(fileSystem, clusterStateDirectory, RAFT_VOTE_NAME, new VoteState.Marshal(new MemberId.Marshal()), config.Get(CausalClusteringSettings.vote_state_size), logProvider));

            raftMembershipStorage = life.Add(new DurableStateStorage <>(fileSystem, clusterStateDirectory, RAFT_MEMBERSHIP_NAME, new RaftMembershipState.Marshal(), config.Get(CausalClusteringSettings.raft_membership_state_size), logProvider));

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

            _leaderAvailabilityTimers = CreateElectionTiming(config, timerService, logProvider);

            int?minimumConsensusGroupSize = config.Get(CausalClusteringSettings.minimum_core_cluster_size_at_runtime);

            MemberIdSetBuilder memberSetBuilder = new MemberIdSetBuilder();

            SendToMyself leaderOnlyReplicator = new SendToMyself(myself, outbound);

            _raftMembershipManager = new RaftMembershipManager(leaderOnlyReplicator, memberSetBuilder, _raftLog, logProvider, minimumConsensusGroupSize.Value, _leaderAvailabilityTimers.ElectionTimeout, systemClock(), config.Get(join_catch_up_timeout).toMillis(), raftMembershipStorage);
            platformModule.Dependencies.satisfyDependency(_raftMembershipManager);

            life.Add(_raftMembershipManager);

            _inFlightCache = InFlightCacheFactory.create(config, platformModule.Monitors);

            RaftLogShippingManager logShipping = new RaftLogShippingManager(outbound, logProvider, _raftLog, timerService, systemClock(), myself, _raftMembershipManager, _leaderAvailabilityTimers.ElectionTimeout, config.Get(catchup_batch_size), config.Get(log_shipping_max_lag), _inFlightCache);

            bool supportsPreVoting = config.Get(CausalClusteringSettings.enable_pre_voting);

            _raftMachine = new RaftMachine(myself, termState, voteState, _raftLog, _leaderAvailabilityTimers, outbound, logProvider, _raftMembershipManager, logShipping, _inFlightCache, config.Get(refuse_to_be_leader), supportsPreVoting, platformModule.Monitors);

            DurationSinceLastMessageMonitor durationSinceLastMessageMonitor = new DurationSinceLastMessageMonitor();

            platformModule.Monitors.addMonitorListener(durationSinceLastMessageMonitor);
            platformModule.Dependencies.satisfyDependency(durationSinceLastMessageMonitor);

            string dbName = config.Get(CausalClusteringSettings.database);

            life.Add(new RaftCoreTopologyConnector(coreTopologyService, _raftMachine, dbName));

            life.Add(logShipping);
        }
Exemple #2
0
 internal ReplicatedContentMarshaller(CoreReplicatedContentMarshal serializer)
 {
     this.Serializer = serializer;
 }