Tabnine Logo
KBucketSet.generateRandomKey
Code IndexAdd Tabnine to your IDE (free)

How to use
generateRandomKey
method
in
net.i2p.kademlia.KBucketSet

Best Java code snippets using net.i2p.kademlia.KBucketSet.generateRandomKey (Showing top 2 results out of 315)

origin: i2p/i2p.i2p

/**
 *  For every bucket that hasn't been updated in this long,
 *  or isn't close to full,
 *  generate a random key that would be a member of that bucket.
 *  The returned keys may be searched for to "refresh" the buckets.
 *  @return non-null, closest first
 */
public List<T> getExploreKeys(long age) {
  List<T> rv = new ArrayList<T>(_buckets.size());
  long old = _context.clock().now() - age;
  getReadLock();
  try {
    for (KBucket<T> b : _buckets) {
      int curSize = b.getKeyCount();
      // Always explore the closest bucket
      if ((b.getRangeBegin() == 0) ||
        (b.getLastChanged() < old || curSize < BUCKET_SIZE * 3 / 4))
        rv.add(generateRandomKey(b));
    }
  } finally { releaseReadLock(); }
  return rv;
}

origin: i2p/i2p.i2p

/** @since 0.9.10 */
public void testGenRandom() {
  int errors = 0;
  for (KBucket<Hash> b : set.getBuckets()) {
    for (int j = 0; j < 4000; j++) {
      Hash rand = set.generateRandomKey(b);
      int range = set.getRange(rand);
      if (range < b.getRangeBegin() || range > b.getRangeEnd()) {
        log.error("Generate random key failed range=" + range + " for " + rand + " meant for bucket " + b);
        errors++;
      }
    }
  }
  assertTrue(errors == 0);
}
net.i2p.kademliaKBucketSetgenerateRandomKey

Javadoc

Generate a random key to go within this bucket Package private for testing only. Others shouldn't need this.

Popular methods of KBucketSet

  • <init>
    Use the supplied trim strategy.
  • add
  • getClosest
    The keys closest to the key. Returned list will never contain us.
  • getExploreKeys
    For every bucket that hasn't been updated in this long, or isn't close to full, generate a random ke
  • toString
  • clear
  • getAll
  • getRange
    The number of bits minus 1 (range number) for the xor of the key. Package private for testing only.
  • remove
  • size
    The current number of entries.
  • createBucket
  • createBuckets
  • createBucket,
  • createBuckets,
  • getBucket,
  • getBuckets,
  • getReadLock,
  • getWriteLock,
  • locked_split,
  • makeKey,
  • pickBucket

Popular in Java

  • Updating database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • setRequestProperty (URLConnection)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • JFrame (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now