示例#1
0
 /**
  * @param key
  * @return
  * @throws RemoteException
  */
 public Finger locateSuccessor(int key) throws RemoteException {
   if (key == i) {
     throw new IllegalArgumentException("Key must be distinct that  " + i);
   }
   if (successor != null && successor.getId() != i) {
     if (in(key, i, successor.getId())) {
       return successor;
     }
     Finger jguid = closestPrecedingNode(key);
     ChordMessageInterface j = rmiChord(jguid.getIp(), jguid.getPort());
     if (j == null) {
       return null;
     }
     return j.locateSuccessor(key);
   }
   return successor;
 }
示例#2
0
 /**
  * @param ip
  * @param port
  * @throws RemoteException
  */
 public void joinRing(String ip, int port) throws RemoteException {
   ChordMessageInterface j = rmiChord(ip, port);
   predecessor = null;
   successor = j.locateSuccessor(i);
 }