Exemplo n.º 1
0
        public void ReplaceNode(Node nodeToRemove, Node nodeToAdd)
        {
            int        distanceFromMaster = _nodeDistanceCalculator.CalculateDistance(MasterNode.IdHash.Bytes, nodeToAdd.IdHash.Bytes);
            NodeBucket bucket             = Buckets[distanceFromMaster > 0 ? distanceFromMaster - 1 : 0];

            _nodes.AddOrUpdate(nodeToAdd.IdHash, nodeToAdd, (x, y) => nodeToAdd);
            _nodes.TryRemove(nodeToRemove.IdHash, out _);
            bucket.ReplaceNode(nodeToRemove, nodeToAdd);
        }
Exemplo n.º 2
0
        public void ReplaceNode(Node nodeToRemove, Node nodeToAdd)
        {
            CheckInitialization();

            int        distanceFromMaster = _nodeDistanceCalculator.CalculateDistance(MasterNode.IdHash.Bytes, nodeToAdd.IdHash.Bytes);
            NodeBucket bucket             = Buckets[distanceFromMaster > 0 ? distanceFromMaster - 1 : 0];

            bucket.ReplaceNode(nodeToRemove, nodeToAdd);
        }