Resolve TODO
This commit is contained in:
@ -78,18 +78,12 @@ pub fn make_listening_node(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn discover(entry_point_info: &NodeInfo, num_nodes: usize) -> Vec<NodeInfo> {
|
pub fn discover(entry_point_info: &NodeInfo, num_nodes: usize) -> Vec<NodeInfo> {
|
||||||
converge(entry_point_info, num_nodes)
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: deprecate this in favor of discover
|
|
||||||
pub fn converge(node: &NodeInfo, num_nodes: usize) -> Vec<NodeInfo> {
|
|
||||||
info!("Wait for convergence with {} nodes", num_nodes);
|
info!("Wait for convergence with {} nodes", num_nodes);
|
||||||
|
|
||||||
let exit = Arc::new(AtomicBool::new(false));
|
let exit = Arc::new(AtomicBool::new(false));
|
||||||
// Let's spy on the network
|
let (gossip_service, spy_ref, id) = make_spy_node(entry_point_info, &exit);
|
||||||
let (gossip_service, spy_ref, id) = make_spy_node(node, &exit);
|
|
||||||
trace!(
|
trace!(
|
||||||
"converge spy_node {} looking for at least {} nodes",
|
"discover: spy_node {} looking for at least {} nodes",
|
||||||
id,
|
id,
|
||||||
num_nodes
|
num_nodes
|
||||||
);
|
);
|
||||||
@ -97,22 +91,19 @@ pub fn converge(node: &NodeInfo, num_nodes: usize) -> Vec<NodeInfo> {
|
|||||||
// Wait for the cluster to converge
|
// Wait for the cluster to converge
|
||||||
for _ in 0..15 {
|
for _ in 0..15 {
|
||||||
let rpc_peers = spy_ref.read().unwrap().rpc_peers();
|
let rpc_peers = spy_ref.read().unwrap().rpc_peers();
|
||||||
if rpc_peers.len() >= num_nodes {
|
info!(
|
||||||
debug!(
|
"discover: spy_node {} found {}/{} nodes",
|
||||||
"converge found {}/{} nodes: {:?}",
|
id,
|
||||||
rpc_peers.len(),
|
rpc_peers.len(),
|
||||||
num_nodes,
|
num_nodes,
|
||||||
rpc_peers
|
|
||||||
);
|
);
|
||||||
|
if rpc_peers.len() >= num_nodes {
|
||||||
exit.store(true, Ordering::Relaxed);
|
exit.store(true, Ordering::Relaxed);
|
||||||
gossip_service.join().unwrap();
|
gossip_service.join().unwrap();
|
||||||
return rpc_peers;
|
return rpc_peers;
|
||||||
}
|
}
|
||||||
debug!(
|
debug!(
|
||||||
"spy_node: {} converge found {}/{} nodes, need {} more",
|
"discover: expecting an additional {} nodes",
|
||||||
id,
|
|
||||||
rpc_peers.len(),
|
|
||||||
num_nodes,
|
|
||||||
num_nodes - rpc_peers.len()
|
num_nodes - rpc_peers.len()
|
||||||
);
|
);
|
||||||
sleep(Duration::new(1, 0));
|
sleep(Duration::new(1, 0));
|
||||||
|
Reference in New Issue
Block a user