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

make configuration change effective on received #202

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
517701f
a little improve about test network
hicqu Sep 27, 2019
8afc14b
Merge branch 'master' into test-improvement
hicqu Sep 27, 2019
d636c81
address comments
hicqu Sep 27, 2019
631403a
address comments
hicqu Sep 29, 2019
e76f8d9
changes about proto to implement conf change on received
hicqu Sep 29, 2019
4fef123
address comments, to make the proto back compatible
hicqu Sep 29, 2019
dd42e25
Merge branch 'proto-change-for-conf-change-on-received' into cc-effec…
hicqu Sep 29, 2019
7059b34
make configuration change active on received
hicqu Sep 29, 2019
4286cec
reworked
hicqu Oct 8, 2019
5f9fcbb
Merge branch 'master' into cc-effective-on-received
hicqu Oct 8, 2019
b394301
Merge branch 'master' into cc-effective-on-received
hicqu Oct 9, 2019
db1d22c
address comments
hicqu Oct 9, 2019
11612ad
fix clippy
hicqu Oct 10, 2019
aa3158d
Merge branch 'master' into cc-effective-on-received
hicqu Oct 10, 2019
99ffd19
address comments
hicqu Oct 10, 2019
4e96ada
address comments
hicqu Oct 11, 2019
8e1acd8
finalize on committed
hicqu Oct 11, 2019
8041bad
remove progress on entry committed instead of received
hicqu Oct 12, 2019
3bb4a02
Merge branch 'master' into cc-effective-on-received
hicqu Oct 12, 2019
a718cb3
fix bechmark
hicqu Oct 12, 2019
335e64a
address comments
hicqu Oct 14, 2019
7f3b91c
address comments
hicqu Oct 16, 2019
13104cc
Merge branch 'master' into cc-effective-on-received
hicqu Oct 16, 2019
d94bc9c
address comments
hicqu Oct 16, 2019
7a5fecd
address comments
hicqu Oct 16, 2019
fb24341
address comments
hicqu Oct 16, 2019
bfa461c
rename ConfStateWithIndex to ConfStateRecord
hicqu Oct 18, 2019
9b6b401
address comments
hicqu Oct 21, 2019
2fa0906
address comments
hicqu Oct 21, 2019
fb34358
address comments
hicqu Oct 22, 2019
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
22 changes: 5 additions & 17 deletions examples/five_mem_node/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use std::{str, thread};

use protobuf::Message as PbMessage;
use raft::eraftpb::ConfState;
use raft::storage::MemStorage;
use raft::{prelude::*, StateRole};
Expand Down Expand Up @@ -251,7 +250,7 @@ fn on_ready(
// Get the `Ready` with `RawNode::ready` interface.
let mut ready = raft_group.ready();

// Persistent raft logs. It's necessary because in `RawNode::advance` we stabilize
// Persist raft logs. It's necessary because in `RawNode::advance` we stabilize
// raft logs to the latest position.
if let Err(e) = store.wl().append(ready.entries()) {
error!(
Expand All @@ -273,6 +272,9 @@ fn on_ready(
}
}

// Persist configuration changes.
store.wl().append_conf_states(&ready.conf_states());

// Send out the messages come from the node.
for msg in ready.messages.drain(..) {
let to = msg.to;
Expand All @@ -291,21 +293,7 @@ fn on_ready(
// From new elected leaders.
continue;
}
if let EntryType::EntryConfChange = entry.get_entry_type() {
// For conf change messages, make them effective.
let mut cc = ConfChange::default();
cc.merge_from_bytes(&entry.data).unwrap();
let node_id = cc.node_id;
match cc.get_change_type() {
ConfChangeType::AddNode => raft_group.raft.add_node(node_id).unwrap(),
ConfChangeType::RemoveNode => raft_group.raft.remove_node(node_id).unwrap(),
ConfChangeType::AddLearnerNode => raft_group.raft.add_learner(node_id).unwrap(),
ConfChangeType::BeginMembershipChange
| ConfChangeType::FinalizeMembershipChange => unimplemented!(),
}
let cs = raft_group.raft.prs().configuration().to_conf_state();
store.wl().set_conf_state(cs, None);
} else {
if EntryType::EntryConfChange != entry.get_entry_type() {
// For normal proposals, extract the key-value pair and then
// insert them into the kv engine.
let data = str::from_utf8(&entry.data).unwrap();
Expand Down
Loading