private void SyncProtocol(string TargetAddress, Tuple <int, int> MyRange, Tuple <int, int> TargetRange)
        {
            this.MUTEX_V.WaitOne();
            this.MUTEX_E.WaitOne();
            this.MUTEX_S.WaitOne();

            TTransport transport = new TSocket(TargetAddress.Split(':')[0], int.Parse(TargetAddress.Split(':')[1]));
            TProtocol  protocol  = new TBinaryProtocol(transport);

            Thrift.TheGraph.Client client = new Thrift.TheGraph.Client(protocol);
            transport.Open();

            BigInteger floor = Handler.BigIntegerOfNBits(MyRange.Item2); //MAIOR NUMERO POSSIVEL NO RANGE ATUAL, ACIMA DISSO DEVE IR PARA O NOVO SERVER

            int stop = this.g.V.Count();

            for (int i = 0; i < stop; i++)
            {
                var v = this.g.V[i];

                if (Handler.HASH_MD5(v.Name.ToString()) > floor)
                {
                    Console.WriteLine(string.Format("Enviando vertice {0} e suas arestas para o servidor {1}", v.Name, TargetAddress));

                    client.copyVertex(v);
                    foreach (var e in this.g.E.Where(edge => edge.V1 == v.Name || (!edge.Directed && edge.V2 == v.Name)))
                    {
                        client.copyEdge(e);
                    }

                    this.g.E.RemoveAll(edge => edge.V1 == v.Name || (!edge.Directed && edge.V2 == v.Name));

                    this.g.V.RemoveAt(i);
                    stop--;
                    i--;
                }
            }

            this.servers[MyAddress] = MyRange;
            this.servers.Add(TargetAddress, TargetRange);

            string message = string.Format("REFRESH|{0}|<{1}, {2}>", MyAddress, MyRange.Item1, MyRange.Item2);

            this.SendMessage(message);

            message = string.Format("REFRESH|{0}|<{1}, {2}>", TargetAddress, TargetRange.Item1, TargetRange.Item2);
            this.SendMessage(message);

            this.MUTEX_V.ReleaseMutex();
            this.MUTEX_E.ReleaseMutex();
            this.MUTEX_S.ReleaseMutex();
        }
        public void DeadProtocol()
        {
            this.MUTEX_V.WaitOne();
            this.MUTEX_E.WaitOne();
            this.MUTEX_S.WaitOne();

            var MyRange = this.servers[MyAddress];

            var TargetAddress         = "";
            Tuple <int, int> newRange = Tuple.Create <int, int>(-1, -1);

            foreach (string server in this.servers.Keys)
            {
                if (MyRange.Item2 != LIMIT_BITS_MD5)   //RIGHT SHIFT
                {
                    if (this.servers[server].Item1 == MyRange.Item2 + 1)
                    {
                        TargetAddress = server;
                        newRange      = Tuple.Create <int, int>(MyRange.Item1, this.servers[server].Item2);
                        break;
                    }
                }
                else     //LEFT SHIFT
                {
                    if (this.servers[server].Item2 == MyRange.Item1 - 1)
                    {
                        TargetAddress = server;
                        newRange      = Tuple.Create <int, int>(this.servers[server].Item1, LIMIT_BITS_MD5);
                        break;
                    }
                }
            }

            if (TargetAddress == string.Empty)
            {
                Console.WriteLine("Não existe outro servidor disponivel, os dados deste serão perdidos");
                return;
            }
            else
            {
                Console.WriteLine(string.Format("Novo servidor responsavel: {0}", TargetAddress));
            }

            string buffer = string.Format("DEAD|{0}|{1}|<{2}, {3}>", TargetAddress, MyAddress, newRange.Item1, newRange.Item2);

            SendMessage(buffer);

            for (; !buffer.Contains("DEAD_OK|") && buffer.Split('|')[1].Equals(MyAddress); buffer = this.ReceiveMessage())
            {
                ;
            }

            TTransport transport = new TSocket(TargetAddress.Split(':')[0], int.Parse(TargetAddress.Split(':')[1]));
            TProtocol  protocol  = new TBinaryProtocol(transport);

            Thrift.TheGraph.Client client = new Thrift.TheGraph.Client(protocol);
            transport.Open();

            foreach (var v in this.g.V)
            {
                Console.WriteLine(string.Format("Enviando vertice {0} para o servidor {1}", v.Name, TargetAddress));
                client.copyVertex(v);
            }

            foreach (var e in this.g.E)
            {
                Console.WriteLine(string.Format("Enviando aresta {0}-{1}-{2} para o servidor {3}", e.V1, e.V2, e.Directed, TargetAddress));
                client.copyEdge(e);
            }

            buffer = string.Format("REFRESH|{0}|<{1}, {2}>", TargetAddress, newRange.Item1, newRange.Item2);
            this.SendMessage(buffer);
            buffer = string.Format("REFRESH|{0}|<{1}, {2}>", MyAddress, -1, -1);
            this.SendMessage(buffer);
        }