Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Lee <BusyJayLee@gmail.com>
  • Loading branch information
BusyJay committed Apr 20, 2020
1 parent eba981b commit ea4bea2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions harness/tests/integration_cases/test_raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4728,26 +4728,28 @@ fn test_request_snapshot_on_role_change() {
/// Tests group commit.
///
/// 1. Logs should be replicated to at least different groups before committed;
/// 2. If no groups has been configured, quorum should be used.
/// 2. If no group is configured or all peers are configured to the same group,
/// simple quorum should be used.
#[test]
fn test_group_commit() {
let l = default_logger();
let mut tests = vec![
// single
// Single
(vec![1], vec![0], 1),
(vec![1], vec![1], 1),
// odd
// Odd
(vec![2, 2, 1], vec![1, 2, 1], 2),
(vec![2, 2, 1], vec![1, 1, 2], 1),
(vec![2, 2, 1], vec![1, 0, 1], 1),
(vec![2, 2, 1], vec![0, 0, 0], 2),
// even
// Even
(vec![4, 2, 1, 3], vec![0, 0, 0, 0], 2),
(vec![4, 2, 1, 3], vec![1, 0, 0, 0], 1),
(vec![4, 2, 1, 3], vec![0, 1, 0, 2], 2),
(vec![4, 2, 1, 3], vec![0, 2, 1, 0], 1),
(vec![4, 2, 1, 3], vec![1, 1, 1, 1], 2),
(vec![4, 2, 1, 3], vec![1, 1, 2, 1], 1),
(vec![4, 2, 1, 3], vec![1, 2, 1, 1], 2),
(vec![4, 2, 1, 3], vec![4, 3, 2, 1], 2),
];

Expand Down
6 changes: 3 additions & 3 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ impl<T: Storage> Raft<T> {
if let Some(pr) = self.mut_prs().get_mut(*peer_id) {
pr.commit_group_id = *group_id;
} else {
return;
continue;
}
}
if StateRole::Leader == self.state && self.maybe_commit() {
Expand Down Expand Up @@ -437,7 +437,7 @@ impl<T: Storage> Raft<T> {
if !self.apply_to_current_term() {
return None;
}
let (index, use_group_commit) = self.prs.as_mut().unwrap().maximal_committed_index();
let (index, use_group_commit) = self.mut_prs().maximal_committed_index();
debug!(
self.logger,
"check group commit consistent";
Expand Down Expand Up @@ -721,7 +721,7 @@ impl<T: Storage> Raft<T> {
/// Attempts to advance the commit index. Returns true if the commit index
/// changed (in which case the caller should call `r.bcast_append`).
pub fn maybe_commit(&mut self) -> bool {
let mci = self.prs.as_mut().unwrap().maximal_committed_index().0;
let mci = self.mut_prs().maximal_committed_index().0;
self.raft_log.maybe_commit(mci, self.term)
}

Expand Down

0 comments on commit ea4bea2

Please # to comment.