예제 #1
0
        private List <MachineLocation> GetMachineLocations(ContentHash contentHash)
        {
            List <MachineLocation> machines = new List <MachineLocation>();

            long contentId = contentHash.LeastSignificantLong();

            using (_ringLock.AcquireReadLock())
            {
                int firstNodeIndex = FindFirstNodeIndex(contentId);
                for (int i = 0; i < Math.Min(_ring.Length, _copiesQuantity); i++)
                {
                    int currentPosition = (firstNodeIndex + i) % _ring.Length;
                    // This implementation of Consistent Hashing does not use virtual nodes
                    machines.Add(_ring[currentPosition].MachineLocation);
                }
            };

            return(machines);
        }