Package org.ardverk.dht.routing

Examples of org.ardverk.dht.routing.Contact


      while (lookupCounter.hasNext()) {
        if (!lookupManager.hasNext()) {
          break;
        }
       
        Contact contact = lookupManager.next();
       
        lookup(contact);
        lookupCounter.increment();
      }
    } finally {
View Full Code Here


   
    public LookupManager(Contact[] contacts, RouteTable routeTable, KUID lookupId) {
      this.routeTable = routeTable;
      this.lookupId = lookupId;
     
      Contact localhost = routeTable.getIdentity();
      KUID contactId = localhost.getId();
     
      XorComparator comparator = new XorComparator(lookupId);
      this.responses = new TreeSet<Contact>(comparator);
      this.closest = new TreeSet<Contact>(comparator);
      this.query = new TreeSet<Contact>(comparator);
View Full Code Here

      return false;
    }
   
    private boolean isCloserThanClosest(Contact other) {
      if (!closest.isEmpty()) {
        Contact contact = closest.last();
        KUID contactId = contact.getId();
        KUID otherId = other.getId();
        return otherId.isCloserTo(lookupId, contactId);
      }
     
      return true;
View Full Code Here

    }
   
    public boolean hasNext(boolean force) {
      if (!query.isEmpty()) {
       
        Contact contact = query.first();
        if (force || exhaustive
            || closest.size() < routeTable.getK()
            || isCloserThanClosest(contact)) {
          return true;
        }
View Full Code Here

     
      return false;
    }
   
    public Contact next() {
      Contact contact = null;
     
      if (randomize && !query.isEmpty()) {
       
        // Knuth: Can we pick a random element from a set of
        // items whose cardinality we do not know?
View Full Code Here

TOP

Related Classes of org.ardverk.dht.routing.Contact

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.