@Test public void testIsFull() { for (KBucket bucket: buckets) { Destination[] destinations = destinationMap.get(bucket); for (int i=0; i<K-1; i++) { bucket.addOrUpdate(new KademliaPeer(destinations[i])); assertFalse(bucket.isFull()); } bucket.addOrUpdate(new KademliaPeer(destinations[K-1])); assertTrue(bucket.isFull()); } }
void addOrUpdate(KademliaPeer peer) { int index = getPeerIndex(peer); if (index >= 0) { KademliaPeer existingPeer = peers.remove(index); existingPeer.responseReceived(); add(existingPeer); } else { if (!isFull()) add(peer); else addOrUpdateReplacement(peer); } }
KBucket extends AbstractBucket { void addOrUpdate(KademliaPeer peer) { int index = getPeerIndex(peer); if (index >= 0) { KademliaPeer existingPeer = peers.remove(index); existingPeer.responseReceived(); add(existingPeer); } else { if (!isFull()) add(peer); else addOrUpdateReplacement(peer); } } }
KBucket extends AbstractBucket { void addOrUpdate(KademliaPeer peer) { int index = getPeerIndex(peer); if (index >= 0) { KademliaPeer existingPeer = peers.remove(index); existingPeer.responseReceived(); add(existingPeer); } else { if (!isFull()) add(peer); else addOrUpdateReplacement(peer); } } KBucket(BigInteger startId, BigInteger endId, int depth); }
KBucket extends AbstractBucket { void addOrUpdate(KademliaPeer peer) { int index = getPeerIndex(peer); if (index >= 0) { KademliaPeer existingPeer = peers.remove(index); existingPeer.responseReceived(); add(existingPeer); } else { if (!isFull()) add(peer); else addOrUpdateReplacement(peer); } } KBucket(BigInteger startId, BigInteger endId, int depth); void setLastLookupTime(long lastLookupTime); long getLastLookupTime(); @Override String toString(); }
KBucket extends AbstractBucket { void addOrUpdate(KademliaPeer peer) { int index = getPeerIndex(peer); if (index >= 0) { KademliaPeer existingPeer = peers.remove(index); existingPeer.responseReceived(); add(existingPeer); } else { if (!isFull()) add(peer); else addOrUpdateReplacement(peer); } } KBucket(BigInteger startId, BigInteger endId, int depth); void setLastLookupTime(long lastLookupTime); long getLastLookupTime(); @Override String toString();  }