Skip to content

Commit

Permalink
[diem-swarm] Add proper support for VFN & PFN
Browse files Browse the repository at this point in the history
Validator full nodes and Public full nodes had no difference in the
DiemSwarm framework.  This led to a bunch of confusion and skipping over
checking if they're connected.  Now, we properly check that there is at
least one outbound proper outbound connection for each full node, and
that the validator full nodes are connected to validators.
  • Loading branch information
gregnazario authored and bors-libra committed Apr 2, 2021
1 parent 5d0a2d3 commit 7d27cc9
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 60 deletions.
27 changes: 27 additions & 0 deletions common/debug-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,38 @@ impl NodeDebugClient {
Self { client, addr }
}

/// Retrieves the individual node metric. Requires all sub fields to match in alphabetical order.
pub fn get_node_metric<S: AsRef<str>>(&mut self, metric: S) -> Result<Option<i64>> {
let metrics = self.get_node_metrics()?;
Ok(metrics.get(metric.as_ref()).cloned())
}

/// Retrieves all node metrics for a given metric name. Allows for filtering metrics by fields afterwards.
pub fn get_node_metric_with_name(
&mut self,
metric: &str,
) -> Result<Option<HashMap<String, i64>>> {
let metrics = self.get_node_metrics()?;
let search_string = format!("{}{{", metric);

let result: HashMap<_, _> = metrics
.iter()
.filter_map(|(key, value)| {
if key.starts_with(&search_string) {
Some((key.clone(), *value))
} else {
None
}
})
.collect();

if result.is_empty() {
Ok(None)
} else {
Ok(Some(result))
}
}

pub fn get_node_metrics(&mut self) -> Result<HashMap<String, i64>> {
let response = self.client.get(&format!("{}/metrics", self.addr)).send()?;

Expand Down
2 changes: 1 addition & 1 deletion config/management/genesis/src/config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl<T: AsRef<Path>> BuildSwarm for ValidatorBuilder<T> {
}
}

#[derive(Debug)]
#[derive(Debug, Copy, Clone)]
pub enum FullnodeType {
ValidatorFullnode,
PublicFullnode(usize),
Expand Down
Loading

0 comments on commit 7d27cc9

Please sign in to comment.