Beispiel #1
0
 private void StartingFromIndexReturnEntries(InFlightCache inFlightCache, long startIndex, RaftLogEntry entry, params RaftLogEntry[] otherEntries)
 {
     when(inFlightCache.Get(startIndex)).thenReturn(entry);
     for (int offset = 0; offset < otherEntries.Length; offset++)
     {
         when(inFlightCache.Get(startIndex + offset + 1L)).thenReturn(otherEntries[offset]);
     }
 }
Beispiel #2
0
 internal ComparableRaftState(MemberId myself, ISet <MemberId> votingMembers, ISet <MemberId> replicationMembers, bool refusesToBeLeader, RaftLog entryLog, InFlightCache inFlightCache, LogProvider logProvider)
 {
     this.MyselfConflict      = myself;
     this._votingMembers      = votingMembers;
     this._replicationMembers = replicationMembers;
     this.EntryLogConflict    = entryLog;
     this._inFlightCache      = inFlightCache;
     this._log = logProvider.getLog(this.GetType());
     this._refusesToBeLeader = refusesToBeLeader;
 }
Beispiel #3
0
 private void AssertCacheIsUpdated(InFlightCache inFlightCache, long key)
 {
     if (ClearCache)
     {
         verify(inFlightCache, times(1)).prune(key);
     }
     else
     {
         verify(inFlightCache, never()).prune(key);
     }
 }
Beispiel #4
0
        public RaftState(MemberId myself, StateStorage <TermState> termStorage, RaftMembership membership, RaftLog entryLog, StateStorage <VoteState> voteStorage, InFlightCache inFlightCache, LogProvider logProvider, bool supportPreVoting, bool refuseToBeLeader)
        {
            this._myself           = myself;
            this._termStorage      = termStorage;
            this._voteStorage      = voteStorage;
            this._membership       = membership;
            this._entryLog         = entryLog;
            this._inFlightCache    = inFlightCache;
            this._supportPreVoting = supportPreVoting;
            this._log = logProvider.getLog(this.GetType());

            // Initial state
            this._isPreElection    = supportPreVoting;
            this._refuseToBeLeader = refuseToBeLeader;
        }
Beispiel #5
0
 public RaftLogShippingManager(Outbound <MemberId, Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> outbound, LogProvider logProvider, ReadableRaftLog raftLog, TimerService timerService, Clock clock, MemberId myself, RaftMembership membership, long retryTimeMillis, int catchupBatchSize, int maxAllowedShippingLag, InFlightCache inFlightCache)
 {
     this._outbound              = outbound;
     this._logProvider           = logProvider;
     this._raftLog               = raftLog;
     this._timerService          = timerService;
     this._clock                 = clock;
     this._myself                = myself;
     this._membership            = membership;
     this._retryTimeMillis       = retryTimeMillis;
     this._catchupBatchSize      = catchupBatchSize;
     this._maxAllowedShippingLag = maxAllowedShippingLag;
     this._inFlightCache         = inFlightCache;
     membership.RegisterListener(this);
 }
Beispiel #6
0
        public RaftMachine(MemberId myself, StateStorage <TermState> termStorage, StateStorage <VoteState> voteStorage, RaftLog entryLog, LeaderAvailabilityTimers leaderAvailabilityTimers, Outbound <MemberId, RaftMessages_RaftMessage> outbound, LogProvider logProvider, RaftMembershipManager membershipManager, RaftLogShippingManager logShipping, InFlightCache inFlightCache, bool refuseToBecomeLeader, bool supportPreVoting, Monitors monitors)
        {
            this._myself = myself;
            this._leaderAvailabilityTimers = leaderAvailabilityTimers;

            this._outbound    = outbound;
            this._logShipping = logShipping;
            this._log         = logProvider.getLog(this.GetType());

            this._membershipManager = membershipManager;

            this._inFlightCache = inFlightCache;
            this._state         = new RaftState(myself, termStorage, membershipManager, entryLog, voteStorage, inFlightCache, logProvider, supportPreVoting, refuseToBecomeLeader);

            _raftMessageTimerResetMonitor = monitors.NewMonitor(typeof(RaftMessageTimerResetMonitor));
        }
Beispiel #7
0
        public CommandApplicationProcess(RaftLog raftLog, int maxBatchSize, int flushEvery, System.Func <DatabaseHealth> dbHealth, LogProvider logProvider, ProgressTracker progressTracker, SessionTracker sessionTracker, CoreState coreState, InFlightCache inFlightCache, Monitors monitors)
        {
            if (!InstanceFieldsInitialized)
            {
                InitializeInstanceFields();
                InstanceFieldsInitialized = true;
            }
            this._raftLog         = raftLog;
            this._flushEvery      = flushEvery;
            this._progressTracker = progressTracker;
            this._sessionTracker  = sessionTracker;
            this._log             = logProvider.getLog(this.GetType());
            this._dbHealth        = dbHealth;
            this._coreState       = coreState;
            this._inFlightCache   = inFlightCache;
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            this._commitIndexMonitor = monitors.NewMonitor(typeof(RaftLogCommitIndexMonitor), this.GetType().FullName);
            this._batcher            = new CommandBatcher(maxBatchSize, this.applyBatch);
            this._batchStat          = StatUtil.create("BatchSize", _log, 4096, true);
        }
Beispiel #8
0
 public virtual RaftMachineBuilder InFlightCache(InFlightCache inFlightCache)
 {
     this._inFlightCache = inFlightCache;
     return(this);
 }