예제 #1
0
 public DurationLogger(Log log, string tag)
 {
     this._log = log;
     this._tag = tag;
     _start    = DateTimeHelper.CurrentUnixTimeMillis();
     log.Debug(format("Started: %s", tag));
 }
예제 #2
0
        public static bool ShouldVoteFor(MemberId candidate, long contextTerm, long requestTerm, long contextLastLogTerm, long requestLastLogTerm, long contextLastAppended, long requestLastLogIndex, bool committedToVotingForAnother, Log log)
        {
            if (requestTerm < contextTerm)
            {
                log.Debug("Will not vote for %s as vote request term %s was earlier than my term %s", candidate, requestTerm, contextTerm);
                return(false);
            }

            bool requestLogEndsAtHigherTerm     = requestLastLogTerm > contextLastLogTerm;
            bool logsEndAtSameTerm              = requestLastLogTerm == contextLastLogTerm;
            bool requestLogAtLeastAsLongAsMyLog = requestLastLogIndex >= contextLastAppended;

            bool requesterLogUpToDate = requestLogEndsAtHigherTerm || (logsEndAtSameTerm && requestLogAtLeastAsLongAsMyLog);

            bool votedForOtherInSameTerm = requestTerm == contextTerm && committedToVotingForAnother;

            bool shouldVoteFor = requesterLogUpToDate && !votedForOtherInSameTerm;

            log.Debug("Should vote for raft candidate %s: " + "requester log up to date: %s " + "(request last log term: %s, context last log term: %s, request last log index: %s, context last append: %s) " + "voted for other in same term: %s " + "(request term: %s, context term: %s, voted for another: %s)", shouldVoteFor, requesterLogUpToDate, requestLastLogTerm, contextLastLogTerm, requestLastLogIndex, contextLastAppended, votedForOtherInSameTerm, requestTerm, contextTerm, committedToVotingForAnother);

            return(shouldVoteFor);
        }
예제 #3
0
        /// <summary>
        /// {@inheritDoc}
        /// </summary>
        public override OUTPUT Apply(INPUT retriableInput, System.Func <INPUT, OUTPUT> retriable, System.Predicate <OUTPUT> wasRetrySuccessful)
        {
            Log    log              = _logProvider.getLog(typeof(MultiRetryStrategy));
            OUTPUT result           = retriable(retriableInput);
            int    currentIteration = 0;

            while (!wasRetrySuccessful(result) && currentIteration++ < _retries)
            {
                log.Debug("Try attempt was unsuccessful for input: %s\n", retriableInput);
                _sleeper.accept(_delayInMillis);
                result = retriable(retriableInput);
            }
            return(result);
        }
예제 #4
0
 public override void ApplyTo(InFlightCache inFlightCache, Log log)
 {
     log.Debug("Start truncating in-flight-map from index %d. Current map:%n%s", FromIndex, inFlightCache);
     inFlightCache.Truncate(FromIndex);
 }