Skip to content

Commit

Permalink
add randomized timeout changing log
Browse files Browse the repository at this point in the history
  • Loading branch information
BusyJay committed Jun 29, 2016
1 parent 1669dc7 commit 761b735
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/raft/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,15 @@ impl<T: Storage> Raft<T> {
}

pub fn reset_randomized_election_timeout(&mut self) {
self.randomized_election_timeout = self.election_timeout +
rand::thread_rng().gen_range(0, self.election_timeout)
let prev_timeout = self.randomized_election_timeout;
let timeout = self.election_timeout +
rand::thread_rng().gen_range(0, self.election_timeout);
debug!("{} {} reset election timeout {} -> {}",
self.tag,
self.id,
prev_timeout,
timeout);
self.randomized_election_timeout = timeout;
}

// check_quorum_active returns true if the quorum is active from
Expand Down

0 comments on commit 761b735

Please sign in to comment.