net.i2p.router.networkdb.kademlia
Class KBucketImpl

java.lang.Object
  extended by net.i2p.router.networkdb.kademlia.KBucketImpl
All Implemented Interfaces:
KBucket

 class KBucketImpl
extends java.lang.Object
implements KBucket


Constructor Summary
KBucketImpl(I2PAppContext context, Hash local)
           
 
Method Summary
 int add(Hash peer)
          Add the peer to the bucket
 Hash generateRandomKey()
          Generate a random key to go within this bucket
 java.util.Set getEntries()
          Retrieve all routing table entries stored in the bucket
 void getEntries(SelectionCollector collector)
           
 java.util.Set getEntries(java.util.Set toIgnoreHashes)
          Retrieve hashes stored in the bucket, excluding the ones specified
 int getKeyCount()
          Number of keys already contained in this kbuckey
 Hash getLocal()
           
 int getRangeBegin()
          lowest order high bit for difference keys
 Hash getRangeBeginKey()
           
 int getRangeEnd()
          highest high bit for the difference keys
 Hash getRangeEndKey()
           
static void main(java.lang.String[] args)
          Test harness to make sure its assigning keys to the right buckets
 boolean remove(Hash peer)
          Remove the key from the bucket
 void setEntries(java.util.Set entries)
          Fill the bucket with entries
 void setRange(int lowOrderBitLimit, int highOrderBitLimit)
          Set the range low and high bits for difference keys
 boolean shouldContain(Hash key)
          whether or not the key qualifies as part of this bucket
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KBucketImpl

public KBucketImpl(I2PAppContext context,
                   Hash local)
Method Detail

getRangeBegin

public int getRangeBegin()
Description copied from interface: KBucket
lowest order high bit for difference keys

Specified by:
getRangeBegin in interface KBucket

getRangeEnd

public int getRangeEnd()
Description copied from interface: KBucket
highest high bit for the difference keys

Specified by:
getRangeEnd in interface KBucket

setRange

public void setRange(int lowOrderBitLimit,
                     int highOrderBitLimit)
Description copied from interface: KBucket
Set the range low and high bits for difference keys

Specified by:
setRange in interface KBucket

getKeyCount

public int getKeyCount()
Description copied from interface: KBucket
Number of keys already contained in this kbuckey

Specified by:
getKeyCount in interface KBucket

getLocal

public Hash getLocal()
Specified by:
getLocal in interface KBucket

shouldContain

public boolean shouldContain(Hash key)
Description copied from interface: KBucket
whether or not the key qualifies as part of this bucket

Specified by:
shouldContain in interface KBucket

getEntries

public java.util.Set getEntries()
Description copied from interface: KBucket
Retrieve all routing table entries stored in the bucket

Specified by:
getEntries in interface KBucket
Returns:
set of Hash structures

getEntries

public java.util.Set getEntries(java.util.Set toIgnoreHashes)
Description copied from interface: KBucket
Retrieve hashes stored in the bucket, excluding the ones specified

Specified by:
getEntries in interface KBucket
Returns:
set of Hash structures

getEntries

public void getEntries(SelectionCollector collector)
Specified by:
getEntries in interface KBucket

setEntries

public void setEntries(java.util.Set entries)
Description copied from interface: KBucket
Fill the bucket with entries

Specified by:
setEntries in interface KBucket
Parameters:
entries - set of Hash structures

add

public int add(Hash peer)
Description copied from interface: KBucket
Add the peer to the bucket

Specified by:
add in interface KBucket
Returns:
number of keys in the bucket after the addition

remove

public boolean remove(Hash peer)
Description copied from interface: KBucket
Remove the key from the bucket

Specified by:
remove in interface KBucket
Returns:
true if the key existed in the bucket before removing it, else false

generateRandomKey

public Hash generateRandomKey()
Generate a random key to go within this bucket

Specified by:
generateRandomKey in interface KBucket

getRangeBeginKey

public Hash getRangeBeginKey()

getRangeEndKey

public Hash getRangeEndKey()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
Test harness to make sure its assigning keys to the right buckets