public JoinChildDtoResponse(DHT dht, List<ValueDtoResponse> data)
 {
     RangeMin = dht.HashRange.Min.ToString();
     RangeMax = dht.HashRange.Max.ToString();
     Child = dht.Child;
     Data = data;
 }
Beispiel #2
0
        public void mergeRange(DHT dht)
        {
            var hashList = new List<BigInteger>{ HashRange.Max, HashRange.Min, dht.HashRange.Max, dht.HashRange.Min };
            hashList.Sort ();

            HashRange.Min = hashList[0];
            HashRange.Max = hashList[3];

            Child = dht.Child;

            //if this is last server
            if (Child == MyPublicUrl) {
                Parent = Child = "";
            }
        }
Beispiel #3
0
        public DHT splitRange(string newChild)
        {
            var newMax = HashRange.Min + ((HashRange.Max - HashRange.Min) / 2);

            var result = new DHT {
                Child = Child,
                HashRange = { Min = newMax, Max = HashRange.Max }
            };

            Child = newChild;
            HashRange.Max = newMax;

            //if parent is empty then set child as child and parent (to make cycle)
            if (string.IsNullOrEmpty (Parent)) {
                Parent = newChild;
            }

            return result;
        }
Beispiel #4
0
        public void mergeRange(DHT dht)
        {
            var hashList = new List <BigInteger> {
                HashRange.Max, HashRange.Min, dht.HashRange.Max, dht.HashRange.Min
            };

            hashList.Sort();

            HashRange.Min = hashList[0];
            HashRange.Max = hashList[3];

            Child = dht.Child;

            //if this is last server
            if (Child == MyPublicUrl)
            {
                Parent = Child = "";
            }
        }
Beispiel #5
0
        public DHT splitRange(string newChild)
        {
            var newMax = HashRange.Min + ((HashRange.Max - HashRange.Min) / 2);

            var result = new DHT {
                Child     = Child,
                HashRange = { Min = newMax, Max = HashRange.Max }
            };

            Child         = newChild;
            HashRange.Max = newMax;

            //if parent is empty then set child as child and parent (to make cycle)
            if (string.IsNullOrEmpty(Parent))
            {
                Parent = newChild;
            }

            return(result);
        }