java.lang.Object
net.i2p.kademlia.RandomTrimmer<T>
net.i2p.kademlia.RandomIfOldTrimmer<T>
- Type Parameters:
T- type of SimpleDataStructure objects in the bucket
- All Implemented Interfaces:
KBucketTrimmer<T>
Removes a random element, but only if the bucket hasn't changed in 5 minutes.
Field Summary
Fields inherited from class RandomTrimmer
_ctxModifier and TypeFieldDescriptionprotected final I2PAppContextThe app context, used for its random() source.Constructor Summary
ConstructorsConstructorDescriptionRandomIfOldTrimmer(I2PAppContext ctx, int max) Create a trimmer that only trims a bucket that hasn't changed in 5 minutes.Method Summary
All Methods
Constructor Details
RandomIfOldTrimmer
Create a trimmer that only trims a bucket that hasn't changed in 5 minutes.- Parameters:
ctx- the application context, supplying the clock used to decide stalenessmax- maximum bucket size
Method Details
trim
Description copied from interface:KBucketTrimmerCalled from add() just before adding the entry. You may call getEntries() and/or remove() from here. Do NOT call add(). To always discard a newer entry, always return false.- Specified by:
trimin interfaceKBucketTrimmer<T extends SimpleDataStructure>- Overrides:
trimin classRandomTrimmer<T extends SimpleDataStructure>- Parameters:
kbucket- the kbucket that is now too bigtoAdd- the entry the bucket is about to accept- Returns:
- true to actually add the entry.