mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
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:
parent
9537cbdb0b
commit
72f651d527
7 changed files with 122 additions and 57 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue