Examples of KUID


Examples of org.ardverk.dht.KUID

    return new DefaultPingResponse(messageId, contact, address);
  }
 
  private NodeRequest readNodeRequest(MessageId messageId,
      Contact contact, SocketAddress address) throws IOException {
    KUID lookupId = readKUID();
    return new DefaultNodeRequest(messageId, contact, address, lookupId);
  }
View Full Code Here

Examples of org.ardverk.dht.KUID

   
    /**
     * Splits the {@link Bucket} in two.
     */
    private DefaultBucket[] split() {
      KUID bucketId = getId();
      int depth = getDepth();
     
      DefaultBucket left = new DefaultBucket(bucketId, depth+1);
      DefaultBucket right = new DefaultBucket(bucketId.set(depth), depth+1);
     
      for (ContactEntry entry : active.values()) {
        KUID contactId = entry.getId();
       
        if (!contactId.isBitSet(depth)) {
          left.add(entry);
        } else {
          right.add(entry);
        }
      }
     
      for (ContactEntry entry : cached.values()) {
        KUID contactId = entry.getId();
        if (!contactId.isBitSet(depth)) {
          left.add(entry);
        } else {
          right.add(entry);
        }
      }
View Full Code Here

Examples of org.ardverk.dht.KUID

   
    handleIoError(entity);
  }
 
  private void handleIoError(RequestEntity entity) {
    KUID contactId = entity.getId();
    SocketAddress address = entity.getAddress();
   
    routeTable.handleIoError(contactId, address);
  }
View Full Code Here

Examples of org.ardverk.dht.KUID

 
  @Override
  public ResponseMessage handleRequest(RequestMessage message) throws IOException {
    NodeRequest request = (NodeRequest)message;
   
    KUID lookupId = request.getId();
   
    // This is an idea where I'm not sure if it's improving anything
    // or not. In short we're excluding the localhost from the result
    // set. The other guy knows us already and our information is in
    // the message header anyways. There is therefore no reason to
View Full Code Here

Examples of org.ardverk.dht.KUID

   
    if (0 < size) {
      writeLong(clock.getCreationTime());
      for (Map.Entry<? extends KUID, ? extends Vector> entry
          : clock.entrySet()) {
        KUID contactId = entry.getKey();
        Vector vector = entry.getValue();
       
        writeKUID(contactId);
        writeVector(vector);
      }
View Full Code Here

Examples of org.ardverk.dht.KUID

  public void encodeDecode() throws IOException {
    BencodeMessageCodec codec
      = new BencodeMessageCodec();
   
    MessageId messageId = MessageId.createRandom(20);
    KUID contactId = KUID.createRandom(20);
   
    Contact contact = new DefaultContact(Type.SOLICITED,
        contactId, 0, false,
        new InetSocketAddress("localhost", 6666));
   
View Full Code Here

Examples of org.ardverk.dht.KUID

    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

Examples of org.ardverk.dht.KUID

       
        if (closest.size() > routeTable.getK()) {
          closest.pollLast();
        }
       
        KUID contactId = contact.getId();
        currentHop = history.get(contactId);
        return true;
      }
     
      return false;
View Full Code Here

Examples of org.ardverk.dht.KUID

     
      return false;
    }
   
    private boolean addToQuery(Contact contact, int hop) {
      KUID contactId = contact.getId();
      if (!history.containsKey(contactId)) {
        history.put(contactId, hop);
        query.add(contact);
        return true;
      }
View Full Code Here

Examples of org.ardverk.dht.KUID

    }
   
    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
TOP
Copyright © 2018 www.massapi.com. 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.