Skip to content
Merged
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
10 changes: 5 additions & 5 deletions crates/ember-cluster/src/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::time::Instant;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::slots::{SlotMap, SlotRange};
use crate::slots::{SlotMap, SlotRange, SLOT_COUNT};
use crate::ClusterError;

/// Unique identifier for a cluster node.
Expand Down Expand Up @@ -408,8 +408,8 @@ impl ClusterState {

/// Generates the response for CLUSTER INFO command.
pub fn cluster_info(&self) -> String {
let primaries: Vec<_> = self.primaries().collect();
let assigned_slots: u16 = primaries.iter().map(|n| n.slot_count()).sum();
let assigned_slots = (SLOT_COUNT as usize - self.slot_map.unassigned_count()) as u16;
let primaries_count = self.primaries().count();

format!(
"cluster_state:{}\r\n\
Expand All @@ -429,7 +429,7 @@ impl ClusterState {
0
},
self.nodes.len(),
primaries.len(),
primaries_count,
self.config_epoch,
self.local_node().map(|n| n.config_epoch).unwrap_or(0),
)
Expand Down Expand Up @@ -566,7 +566,7 @@ mod tests {
let info = state.cluster_info();

assert!(info.contains("cluster_state:ok"));
assert!(info.contains("cluster_slots_assigned:0")); // slots in node.slots, not slot_map
assert!(info.contains("cluster_slots_assigned:16384"));
assert!(info.contains("cluster_known_nodes:1"));
}

Expand Down
Loading
Loading