public void RemoveSlot(IHashSlot slot) { var slotNumber = slot.ToInt(); var containingRanges = _ranges.Where(kvp => slotNumber >= kvp.Key && slotNumber <= kvp.Value).ToList(); foreach (var containingRange in containingRanges) { _ranges.Remove(containingRange.Key); if (containingRange.Key == containingRange.Value) continue; if (containingRange.Key == slotNumber) { _ranges[slotNumber + 1] = containingRange.Value; } else if (containingRange.Value == slotNumber) { _ranges[containingRange.Key] = slotNumber - 1; } else { _ranges[containingRange.Key] = slotNumber - 1; _ranges[slotNumber + 1] = containingRange.Value; } } }
public void Add(IHashSlot slot) { var slotNumber = slot.ToInt(); if (_ranges.Count(kvp => slotNumber >= kvp.Key && slotNumber <= kvp.Value) == 0) _ranges[slotNumber] = slotNumber; }
public static Exception RetriedMovedKeyUntilLimitReached(IHashSlot slot, int movedKeyRetriesLeft) { return new Exception("Could not find key; reported MOVED more than MaximumMovedKeyRetries"); }
public bool Contains(IHashSlot slot) { var slotNumber = slot.ToInt(); return _ranges.Count(kvp => slotNumber >= kvp.Key && slotNumber <= kvp.Value) > 0; }
public static Exception CouldNotFindSlotOwner(IHashSlot slot) { return new Exception("No node owns slot " + slot.ToInt()); }