Esempio n. 1
0
 public ChordNode(string myAddress, int myPort)
 {
     Predecessor = null;
     keyTable = new Dictionary<BigInteger, List<string>>();
     fingers = new NodeInfo[chordKeyLength];
     successors = ArrayList.Synchronized(new ArrayList());
     myData = new NodeInfo(myAddress, myPort, new BigInteger(SHA(myAddress + ":" + myPort)));
     byte[] max = new byte[20];
     for (int i = 0; i < 20; i++)
         max[i] = 255;
     maxValue = new BigInteger(max);
     for(int i = 0; i < MAX_SUCESSORS; i++)
         successors.Add(myData);
 }
Esempio n. 2
0
 public ArrayList Notify(NodeInfo pred)
 {
     ChordModule.Instance.NodeInstance.Notify(pred);
     return ChordModule.Instance.NodeInstance.Successors;
 }
Esempio n. 3
0
 public ChordNode(string myAddress, int myPort, string knownChordNodeAddress, int knownChordNodePort)
 {
     Predecessor = null;
     fingers = new NodeInfo[chordKeyLength];
     successors = ArrayList.Synchronized(new ArrayList());
     myData = new NodeInfo(myAddress, myPort, new BigInteger(SHA(myAddress + ":" + myPort)));
     byte[] max = new byte[20];
     for (int i = 0; i < 20; i++)
         max[i] = 255;
     maxValue = new BigInteger(max);
     NodeInfo ni = Join(knownChordNodeAddress, knownChordNodePort);
     if (ni != null)
     {
         //In the beginning this node should only know it's sucessor.
         //So we initialize them all as the same one.
         for (int i = 0; i < MAX_SUCESSORS; i++)
             successors.Add(ni);
         ChordNodeProxy obj = (ChordNodeProxy)Activator.GetObject(typeof(ChordNodeProxy), ni.Address + ":" + ni.Port + "/ChordServices");
         if (obj != null)
         {
             try
             {
                 keyTable = obj.CopyKeys(myData.ID);
             }
             catch (IOException) { }
             catch (SocketException) { }
         }
     }
     else
     {
         //known node is dead
         throw new ServiceUnavailableException("Known chord node is dead.");
     }
 }
Esempio n. 4
0
 public void Notify(NodeInfo pred)
 {
     if (((NodeInfo)successors[0]).Equals(myData))
         successors[0] = pred;
     if (Predecessor == null ||
         TestKey(Predecessor.ID,pred.ID,myData.ID))
         Predecessor = pred;
 }
Esempio n. 5
0
 public ArrayList Notify(NodeInfo pred)
 {
     ChordModule.Instance.NodeInstance.Notify(pred);
     return(ChordModule.Instance.NodeInstance.Successors);
 }