Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce follower replication #249

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions harness/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,21 @@ impl Network {
/// Read out all messages generated by peers in the `Network`.
///
/// Note: messages are not filtered by any configured filters.
#[inline]
pub fn read_messages(&mut self) -> Vec<Message> {
self.peers
.iter_mut()
.flat_map(|(_peer, progress)| progress.read_messages())
.collect()
}

#[inline]
hicqu marked this conversation as resolved.
Show resolved Hide resolved
pub fn read_peer_messages(&mut self, id: u64) -> Vec<Message> {
self.peers
.get_mut(&id)
.map_or(vec![], |node| node.read_messages())
}

/// Instruct the cluster to `step` through the given messages.
///
/// NOTE: the given `msgs` won't be filtered by its filters.
Expand Down
1 change: 1 addition & 0 deletions harness/tests/integration_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

mod test_raft;
mod test_raft_flow_control;
mod test_raft_follower_replication;
mod test_raft_paper;
mod test_raft_snap;
mod test_raw_node;
2 changes: 1 addition & 1 deletion harness/tests/integration_cases/test_raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ fn test_handle_msg_append() {
);

sm.become_follower(2, INVALID_ID);
sm.handle_append_entries(&m);
sm.handle_append_message(m);
if sm.raft_log.last_index() != w_index {
panic!(
"#{}: last_index = {}, want {}",
Expand Down
Loading