Package org.ardverk.dht

Examples of org.ardverk.dht.DHT


    boolean success = false;
    try {
      for (int i = 0; i < count; i++) {
        int prt = port+i;
       
        DHT dht = factory.newDHT(prt);
       
        dht.bind(new DatagramTransport(
            new BencodeMessageCodec(), prt));
        dhts.add(dht);
      }
      success = true;
    } finally {
View Full Code Here


    if (dhts.size() <= 1) {
      throw new IllegalArgumentException();
    }
   
    // Bootstrap everyone from the first DHT
    DHT first = dhts.get(0);
    List<DHTFuture<BootstrapEntity>> futures1
      = bootstrap(first.getIdentity(), dhts, 1, dhts.size()-1);
   
    // The RouteTable is all messed up! Clear it and bootstrap
    // the first DHT from the others.
    ((DefaultRouteTable)first.getRouteTable()).clear();
    TestCase.assertEquals(1, first.getRouteTable().size());
   
    List<DHTFuture<BootstrapEntity>> futures2
      = bootstrap(dhts.get(1).getIdentity(), dhts, 0, 1);
   
    futures2.addAll(futures1);
View Full Code Here

          new XorComparator(lookupId));
      for (DHT dht : dhts) {
        expected.add(dht.getIdentity().getId());
      }
     
      DHT first = dhts.get(0);
     
      NodeConfig config = new NodeConfig();
      config.setLookupTimeout(20L, TimeUnit.SECONDS);
     
      DHTFuture<NodeEntity> future
        = first.discover(lookupId, config);
      NodeEntity entity = future.get();
      TestCase.assertEquals(lookupId, entity.getId());
     
      Contact[] contacts = entity.getContacts();
      Contact[] closest = entity.getClosest();
     
      // The Contacts in the response should be in the same order
      // as our DHT instances!
      int k = first.getRouteTable().getK();
      for (int i = 0; i < k && i < contacts.length; i++) {
        KUID contactId = contacts[i].getId();
        KUID closestId = closest[i].getId();
       
        KUID expectedId = expected.pollFirst();
View Full Code Here

TOP

Related Classes of org.ardverk.dht.DHT

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.