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
29 changes: 7 additions & 22 deletions crates/ember-server/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,10 @@ impl ClusterCoordinator {
// validate: all slots must be unassigned
for &slot in slots {
if slot >= SLOT_COUNT {
return Frame::Error(format!(
"ERR Invalid or out of range slot {slot}"
));
return Frame::Error(format!("ERR Invalid or out of range slot {slot}"));
}
if state.slot_map.owner(slot).is_some() {
return Frame::Error(format!(
"ERR Slot {slot} is already busy"
));
return Frame::Error(format!("ERR Slot {slot} is already busy"));
}
}

Expand All @@ -210,20 +206,14 @@ impl ClusterCoordinator {
// validate: all slots must be owned by us
for &slot in slots {
if slot >= SLOT_COUNT {
return Frame::Error(format!(
"ERR Invalid or out of range slot {slot}"
));
return Frame::Error(format!("ERR Invalid or out of range slot {slot}"));
}
match state.slot_map.owner(slot) {
Some(owner) if owner != self.local_id => {
return Frame::Error(format!(
"ERR Slot {slot} is not owned by this node"
));
return Frame::Error(format!("ERR Slot {slot} is not owned by this node"));
}
None => {
return Frame::Error(format!(
"ERR Slot {slot} is already unassigned"
));
return Frame::Error(format!("ERR Slot {slot} is already unassigned"));
}
_ => {}
}
Expand Down Expand Up @@ -277,13 +267,8 @@ impl ClusterCoordinator {
}

match state.slot_owner(slot) {
Some(owner) => Some(Frame::Error(format!(
"MOVED {} {}",
slot, owner.addr
))),
None => Some(Frame::Error(
"CLUSTERDOWN Hash slot not served".into(),
)),
Some(owner) => Some(Frame::Error(format!("MOVED {} {}", slot, owner.addr))),
None => Some(Frame::Error("CLUSTERDOWN Hash slot not served".into())),
}
}

Expand Down
Loading