Пример #1
0
            public Engine(PastryRealNode n, IPastryNode joinOtherPastryNode)
            {
/*
 *                              self = n;
 *                              try
 *                              {
 *                                      selfPastryNodeBasic = new Tashjik.Common.PastryNodeBasic(Tashjik.Common.UtilityMethod.GetLocalHostIP());
 *                              }
 *                              catch (Tashjik.Common.Exception.LocalHostIPNotFoundException e)
 *                              {
 *                                      //local ip could not be found :O :O
 *                                      //crash the system
 *                                      //dunno how to do it though :(
 *                              }
 *
 *                              initialize();
 *                              joinOther(joinOtherPastryNode);
 */
            }
Пример #2
0
        private static int sharedPrefixLength(PastryRealNode n, byte[] hash)
        {
            byte[] PastryNodeHashedIP = n.getHashedIP();
            int    maxLength          = PastryNodeHashedIP.Length;
            int    prefixCount        = 0;

            if (hash.Length > maxLength)
            {
                maxLength = hash.Length;
            }
            for (int i = 0; i < maxLength; i++)
            {
                if (PastryNodeHashedIP[i] != hash[i])
                {
                    break;
                }
                prefixCount++;
            }
            return(prefixCount);
        }
Пример #3
0
            public Engine(PastryRealNode n)
            {
                self = n;
                try
                {
                    selfPastryNodeBasic = new Tashjik.Common.NodeBasic(Tashjik.Common.UtilityMethod.GetLocalHostIP());
                }
                catch (Tashjik.Common.Exception.LocalHostIPNotFoundException e)
                {
                    //local ip could not be found :O :O
                    //crash the system
                    //dunno how to do it though :(
                }

                //routingTable     = new PastryNodeEntry[(int) (Math.Pow(2, b)-1), 128/b];
                //smallerLeafSet   = new List<PastryNodeEntry>(L/2);
                //largerLeafSet    = new List<PastryNodeEntry>(L/2);


                initialize();
            }
Пример #4
0
            public Engine(PastryRealNode n, IPastryNode joinOtherPastryNode)
            {
                /*
                self = n;
                try
                {
                    selfPastryNodeBasic = new Tashjik.Common.PastryNodeBasic(Tashjik.Common.UtilityMethod.GetLocalHostIP());
                }
                catch (Tashjik.Common.Exception.LocalHostIPNotFoundException e)
                {
                    //local ip could not be found :O :O
                    //crash the system
                    //dunno how to do it though :(
                }

                initialize();
                joinOther(joinOtherPastryNode);
                */
            }
Пример #5
0
            public Engine(PastryRealNode n)
            {
                self = n;
                try
                {
                    selfPastryNodeBasic = new Tashjik.Common.NodeBasic(Tashjik.Common.UtilityMethod.GetLocalHostIP());
                }
                catch (Tashjik.Common.Exception.LocalHostIPNotFoundException e)
                {
                    //local ip could not be found :O :O
                    //crash the system
                    //dunno how to do it though :(
                }

                //routingTable     = new PastryNodeEntry[(int) (Math.Pow(2, b)-1), 128/b];
                //smallerLeafSet   = new List<PastryNodeEntry>(L/2);
                //largerLeafSet    = new List<PastryNodeEntry>(L/2);

                initialize();
            }
Пример #6
0
 private static int sharedPrefixLength(PastryRealNode n, byte[] hash)
 {
     byte[] PastryNodeHashedIP = n.getHashedIP();
         int maxLength = PastryNodeHashedIP.Length;
         int prefixCount = 0;
         if(hash.Length > maxLength)
             maxLength = hash.Length;
         for(int i=0; i<maxLength; i++)
         {
             if(PastryNodeHashedIP[i]!= hash[i])
                 break;
             prefixCount++;
         }
         return prefixCount;
 }