Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
Signed-off-by: Akira Hayakawa <ruby.wktk@gmail.com>
  • Loading branch information
akiradeveloper committed Mar 5, 2024
1 parent 364a16b commit 8714da8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lol2/src/process/peer_svc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct ThreadHandles {
}

pub struct Inner {
membership: spin::RwLock<HashSet<NodeId>>,
peer_contexts: spin::RwLock<HashMap<NodeId, PeerContexts>>,
peer_threads: spin::Mutex<HashMap<NodeId, ThreadHandles>>,

Expand All @@ -44,6 +45,7 @@ pub struct PeerSvc(pub Arc<Inner>);
impl PeerSvc {
pub fn new(command_log: Ref<CommandLog>, driver: RaftDriver) -> Self {
let inner = Inner {
membership: HashSet::new().into(),
peer_contexts: HashMap::new().into(),
peer_threads: HashMap::new().into(),
command_log,
Expand Down Expand Up @@ -151,7 +153,9 @@ impl PeerSvc {
for id in remove_peers {
self.remove_peer(id);
}

info!("membership changed -> {:?}", config);
*self.membership.write() = config;

self.command_log
.membership_pointer
Expand All @@ -161,11 +165,7 @@ impl PeerSvc {
}

pub fn read_membership(&self) -> HashSet<NodeId> {
let mut out = HashSet::new();
for (id, _) in self.peer_contexts.read().iter() {
out.insert(id.clone());
}
out
self.membership.read().clone()
}

pub async fn find_new_commit_index(&self) -> Result<Index> {
Expand Down

0 comments on commit 8714da8

Please sign in to comment.