// Get the Physical server where a key is mapped to
        public Server GetServerForKey(String key)
        {
            Server serverHoldingKey;

            if (_hashRing.Count == 0)
            {
                return(null);
            }
            // Get the hash for the key
            uint hashKey = FNVHash.To32BitFnv1aHash(key);

            if (_hashRing.ContainsKey(hashKey))
            {
                serverHoldingKey = this._hashRing[hashKey];
            }
            else
            {
                uint[] sortedKeys = _hashRing.Keys.ToArray();
                //Find the first server key greater than  the hashkey
                uint firstServerKey = sortedKeys.FirstOrDefault(x => x >= hashKey);
                // Get the Server at that Hashkey
                serverHoldingKey = _hashRing[firstServerKey];
            }
            return(serverHoldingKey);
        }
 public void RemoveServerFromHashRing(Server server)
 {
     for (int i = 0; i < _numberOfReplicas; i++)
     {
         //Fuse the server ip with the replica number
         string serverIdentity = String.Concat(server.IpAddress, ":", i);
         //Get the hash key of the server
         uint hashKey = FNVHash.To32BitFnv1aHash(serverIdentity);
         //Insert the server at the hashkey in the Sorted Dictionary
         _hashRing.Remove(hashKey);
     }
 }