NodeResponseHandler extends LookupResponseHandler<NodeEntity> { @Override protected void lookup(Contact dst, KUID lookupId, long timeout, TimeUnit unit) throws IOException { MessageFactory factory = getMessageFactory(); NodeRequest message = factory.createNodeRequest(dst, lookupId); send(dst, message, timeout, unit); } NodeResponseHandler(Provider<MessageDispatcher> messageDispatcher,
      Contact[] contacts, RouteTable routeTable, KUID lookupId, NodeConfig config);   }
@Test public void lookup() throws Exception { List<DHT> dhts = createDHTs(256, 2000); try { bootstrap(dhts); KUID lookupId = KUID.createRandom(20); TreeSet<KUID> expected = new TreeSet<KUID>( 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(); 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(); TestCase.assertEquals(expectedId, contactId); TestCase.assertEquals(expectedId, closestId); TestCase.assertSame(closest[i], contacts[i]); } } finally { IoUtils.closeAll(dhts); } }