feat(cluster): add slots blocking when we finalize migration (#2484)

* feat(cluster): add slots blocking when we finalize the migration
This commit is contained in:
Borys 2024-02-07 15:19:35 +02:00 committed by GitHub
parent 9537cbdb0b
commit 72f651d527
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 122 additions and 57 deletions

View file

@ -311,6 +311,12 @@ bool ClusterConfig::IsMySlot(std::string_view key) const {
return IsMySlot(KeySlot(key));
}
void ClusterConfig::RemoveSlots(SlotSet slots) {
for (const auto s : slots) {
my_slots_.set(s, false);
}
}
ClusterConfig::Node ClusterConfig::GetMasterNodeForSlot(SlotId id) const {
CHECK_LT(id, my_slots_.size()) << "Requesting a non-existing slot id " << id;
@ -340,4 +346,13 @@ SlotSet ClusterConfig::GetOwnedSlots() const {
return set;
}
SlotSet ToSlotSet(const std::vector<ClusterConfig::SlotRange>& slots) {
SlotSet sset;
for (const auto& slot_range : slots) {
for (auto i = slot_range.start; i <= slot_range.end; ++i)
sset.insert(i);
}
return sset;
}
} // namespace dfly