Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ default-logger = ["slog-stdlog", "slog-envlogger", "slog-term"]
# Make sure to synchronize updates with Harness.
[dependencies]
bytes = { version = "1.11", optional = true }
fxhash = "0.2.1"
fail = { version = "0.4", optional = true }
getset = "0.1.1"
thiserror = "1.0"
raft-proto = { path = "proto", version = "0.7.0", default-features = false }
rand = "0.8"
rustc-hash = "2.1.1"
slog = "2.2"
slog-envlogger = { version = "2.1.0", optional = true }
slog-stdlog = { version = "4", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion harness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ slog = "2.2"

[dev-dependencies]
criterion = "0.3"
fxhash = "0.2.1"
rustc-hash = "2.1.1"
lazy_static = "1"
protobuf = "2"
regex = "1"
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 @@ -29,7 +29,7 @@ use slog::Logger;
use crate::integration_cases::test_raft_paper::commit_noop_entry;
use crate::test_util::*;

type HashSet<K> = std::collections::HashSet<K, std::hash::BuildHasherDefault<fxhash::FxHasher>>;
type HashSet<K> = rustc_hash::FxHashSet<K>;

fn read_messages<T: Storage>(raft: &mut Raft<T>) -> Vec<Message> {
raft.msgs.drain(..).collect()
Expand Down
14 changes: 10 additions & 4 deletions harness/tests/integration_cases/test_raw_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ fn test_raw_node_propose_and_conf_change() {
let cs = conf_state_v2(vec![2], vec![3], vec![1], vec![1], true);
test_cases.push((Box::new(cc), cs, Some(conf_state(vec![2], vec![1, 3]))));

for (cc, exp, exp2) in test_cases {
for (cc, mut exp, exp2) in test_cases {
let s = new_storage();
let mut raw_node = new_raw_node(1, vec![1], 10, 1, s.clone(), &l);
raw_node.campaign().unwrap();
Expand Down Expand Up @@ -320,7 +320,10 @@ fn test_raw_node_propose_and_conf_change() {
assert_eq!(entries[1].get_entry_type(), EntryType::EntryConfChangeV2);
}
assert_eq!(ccdata, entries[1].get_data());
assert_eq!(exp, cs.unwrap());
let mut cs = cs.unwrap();
exp.voters.sort();
cs.voters.sort();
assert_eq!(exp, cs);

let conf_index = if cc.as_v2().enter_joint() == Some(true) {
// If this is an auto-leaving joint conf change, it will have
Expand Down Expand Up @@ -365,8 +368,11 @@ fn test_raw_node_propose_and_conf_change() {
assert_eq!(context, leave_cc.get_context(), "{:?}", cc.as_v2());
// Lie and pretend the ConfChange applied. It won't do so because now
// we require the joint quorum and we're only running one node.
let cs = raw_node.apply_conf_change(&leave_cc).unwrap();
assert_eq!(cs, exp2.unwrap());
let mut cs = raw_node.apply_conf_change(&leave_cc).unwrap();
cs.learners.sort();
let mut exp2 = exp2.unwrap();
exp2.learners.sort();
assert_eq!(cs, exp2);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,6 @@ pub fn default_logger() -> slog::Logger {
}
}

type DefaultHashBuilder = std::hash::BuildHasherDefault<fxhash::FxHasher>;
type DefaultHashBuilder = std::hash::BuildHasherDefault<rustc_hash::FxHasher>;
type HashMap<K, V> = std::collections::HashMap<K, V, DefaultHashBuilder>;
type HashSet<K> = std::collections::HashSet<K, DefaultHashBuilder>;
30 changes: 16 additions & 14 deletions src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,39 @@ pub struct Configuration {
#[cfg(test)]
impl std::fmt::Display for Configuration {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn iter_to_sorted_string(iter: impl Iterator<Item = impl ToString + Ord>) -> String {
iter.sorted()
.map(|x| x.to_string())
.collect::<Vec<String>>()
.join(" ")
}
use itertools::Itertools;
if self.voters.outgoing.is_empty() {
write!(f, "voters={}", self.voters.incoming)?
write!(
f,
"voters=({})",
iter_to_sorted_string(self.voters.incoming.iter())
)?
} else {
write!(
f,
"voters={}&&{}",
self.voters.incoming, self.voters.outgoing
"voters=({})&&({})",
iter_to_sorted_string(self.voters.incoming.iter()),
iter_to_sorted_string(self.voters.outgoing.iter())
)?
}
if !self.learners.is_empty() {
write!(
f,
" learners=({})",
self.learners
.iter()
.sorted_by(|&a, &b| a.cmp(b))
.map(|x| x.to_string())
.collect::<Vec<String>>()
.join(" ")
iter_to_sorted_string(self.learners.iter())
)?
}
if !self.learners_next.is_empty() {
write!(
f,
" learners_next=({})",
self.learners_next
.iter()
.map(|x| x.to_string())
.collect::<Vec<String>>()
.join(" ")
iter_to_sorted_string(self.learners_next.iter())
)?
}
if self.auto_leave {
Expand Down
Loading