/// <summary> /// Remove exist node /// </summary> /// <param name="node">Node</param> public void RemoveNode(Node node) { Nodes.Remove(node.NodeID); for (int i = 0; i < vNodes; i++) { int token = Hash(node.GetHashCode().ToString() + i); if (!ring.Remove(token)) { throw new Exception("can not remove a node that not added"); } } ayKeys = ring.Keys.ToArray(); }
private void AddNode(Node node, bool updateKeyArray = false) { List <Token> tokens = new List <Token>(); for (int i = 0; i < vNodes; i++) { int token = Hash(node.GetHashCode().ToString() + i); tokens.Add(new Token(token, node.NodeID)); ring[token] = node; } if (updateKeyArray) { ayKeys = ring.Keys.ToArray(); } node.AssignToken(tokens); Nodes.Add(node.NodeID, node); }