Package info.walnutstreet.vs.ps04.p2p.ring

Examples of info.walnutstreet.vs.ps04.p2p.ring.Node


   
    int maxNum = this.localNode.numberOfNodes();
    for (int i = 0; i < Math.sqrt(maxNum); i++) {
      int nextId = (this.localNode.getId() + (int)Math.pow(2, i)) % P2PFingerTable.MODULO_VALUE;
     
      NodeInterface nodeThatAlreadyExists = this.getEntry(nextId);
      if (nodeThatAlreadyExists == null) { // if the node with the id 'nextId' doesn't exists
        NodeInterface predecessorOfSearchedNextId = this.getPrevFTEntry(nextId);
        NodeInterface nodeWithIdAsNextId = null;
        if (predecessorOfSearchedNextId == null) { // no predecessor exists
          nodeWithIdAsNextId = this.localNode.lookup(nextId);
        } else { // ok, we have a predecessor in the table
          nodeWithIdAsNextId = predecessorOfSearchedNextId.lookupChord(nextId);
        }
View Full Code Here


  }

  public NodeInterface getEntry(int nextId) throws RemoteException {
    Set<Integer> set = this.remoteNodes.keySet();
    for (Integer integer : set) {
      NodeInterface node = this.remoteNodes.get(integer);
      if (node.getId() == nextId)
        return node;
    }
    return null;
  }
View Full Code Here

    return null;
  }
 
  private NodeInterface getPrevFTEntry(int nextid) throws RemoteException {
    Set<Integer> ids = this.remoteNodes.keySet();
    NodeInterface n = null;
   
    for (Integer integer : ids) {
      NodeInterface node = this.remoteNodes.get(integer);
      if (node.getId() < nextid)
        n = node;
      else
        break;
    }
   
View Full Code Here

  /* (non-Javadoc)
   * @see info.walnutstreet.vs.ps04.p2p.ring.interfaces.NodeInterface#lookupChord(int)
   */
  @Override
  public NodeInterface lookupChord(int nextId) throws RemoteException {
    NodeInterface node = this.fingerTable.getEntry(nextId);
    if (node != null) {
      return node;
    }
    return this.lookup(nextId);
  }
View Full Code Here

TOP

Related Classes of info.walnutstreet.vs.ps04.p2p.ring.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.