## net.i2p.router.networkdb.kademlia
Class KademliaNetworkDatabaseFacade

    java.lang.Object
      net.i2p.router.NetworkDatabaseFacade
          net.i2p.router.networkdb.kademlia.KademliaNetworkDatabaseFacade

All Implemented Interfaces:
  Service

Direct Known Subclasses:
  FloodfillNetworkDatabaseFacade

    public class KademliaNetworkDatabaseFacade

extends NetworkDatabaseFacade

Kademlia based version of the network database

Field Summary
`protected RouterContext` `_context`
`protected Log` `_log`
`protected PeerSelector` `_peerSelector`
`static java.lang.String` `DEFAULT_DB_DIR`
`(package private) static long` `MAX_LEASE_FUTURE` Don't let leaseSets go 20 minutes into the future
`static java.lang.String` `PROP_DB_DIR`
`static java.lang.String` `PROP_ENFORCE_NETID`

Constructor Summary
`KademliaNetworkDatabaseFacade(RouterContext context)`

Method Summary
`protected void` `createHandlers()`
`protected PeerSelector` `createPeerSelector()`
`protected void` `dropAfterLookupFailed(Hash peer, RouterInfo info)`
`void` `fail(Hash dbEntry)`
`java.util.Set` `findNearestRouters(Hash key, int maxNumRouters, java.util.Set peersToIgnore)` Get the routers closest to that key in response to a remote lookup
`(package private) java.util.Set` `getAllRouters()` get the hashes for all known routers
`(package private) DataStore` `getDataStore()`
`(package private) java.lang.String` `getDbDir()`
`java.util.Set` `getExplicitSendKeys()`
`java.util.Set` `getExploreKeys()`
`(package private) KBucketSet` `getKBuckets()`
`int` `getKnownLeaseSets()`
`int` `getKnownRouters()`
`(package private) long` `getLastExploreNewDate()`
`java.lang.Long` `getLastSent(Hash key)`
`java.util.Set` `getPassivelySendKeys()`
`PeerSelector` `getPeerSelector()`
`int` `getPeerTimeout(Hash peer)`
`protected void` `lookupBeforeDropping(Hash peer, RouterInfo info)`
`void` `lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs)`
`LeaseSet` `lookupLeaseSetLocally(Hash key)`
`void` `lookupRouterInfo(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs)`
`RouterInfo` `lookupRouterInfoLocally(Hash key)`
`void` `noteKeySent(Hash key)`
`void` `publish(LeaseSet localLeaseSet)`
`void` `publish(RouterInfo localRouterInfo)`
`void` `queueForExploration(java.util.Set keys)`
`void` `queueForPublishing(java.util.Set toSend)`
`void` `removeFromExplicitSend(java.util.Set toRemove)`
`void` `removeFromExploreKeys(java.util.Set toRemove)`
`void` `removeFromPassiveSend(java.util.Set toRemove)`
`void` `renderStatusHTML(java.io.Writer out)`
`void` `restart()` Perform a soft restart.
`(package private) SearchJob` `search(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease)` Begin a kademlia style search for the key specified, which can take up to timeoutMs and will fire the appropriate jobs on success or timeout (or if the kademlia search completes without any match)
`(package private) void` `searchComplete(Hash key)` The search for the given key is no longer active
`void` `sendStore(Hash key, DataStructure ds, Job onSuccess, Job onFailure, long sendTimeout, java.util.Set toIgnore)`
`(package private) void` `setLastExploreNewDate(long when)`
`void` `shutdown()` Instruct the service that the router is shutting down and that it should do whatever is necessary to go down gracefully.
`void` `startup()` Instruct the service that it should start normal operation.
`(package private) void` `stopPublishing(Hash target)`
`LeaseSet` `store(Hash key, LeaseSet leaseSet)` Store the leaseSet
`RouterInfo` `store(Hash key, RouterInfo routerInfo)` store the routerInfo
`void` `unpublish(LeaseSet localLeaseSet)`
`(package private) java.lang.String` `validate(Hash key, LeaseSet leaseSet)` Determine whether this leaseSet will be accepted as valid and current given what we know now.
`(package private) java.lang.String` `validate(Hash key, RouterInfo routerInfo)` Determine whether this routerInfo will be accepted as valid and current given what we know now.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _log

    protected Log _log

### _peerSelector

    protected PeerSelector _peerSelector

### _context

    protected RouterContext _context

### PROP_ENFORCE_NETID

    public static final java.lang.String PROP_ENFORCE_NETID

See Also:
  Constant Field Values

### PROP_DB_DIR

    public static final java.lang.String PROP_DB_DIR

See Also:
  Constant Field Values

### DEFAULT_DB_DIR

    public static final java.lang.String DEFAULT_DB_DIR

See Also:
  Constant Field Values

### MAX_LEASE_FUTURE

    static final long MAX_LEASE_FUTURE

  Don't let leaseSets go 20 minutes into the future

  See Also:
    Constant Field Values

Constructor Detail

### KademliaNetworkDatabaseFacade

    public KademliaNetworkDatabaseFacade(RouterContext context)

Method Detail

### searchComplete

    void searchComplete(Hash key)

  The search for the given key is no longer active

### createPeerSelector

    protected PeerSelector createPeerSelector()

### getPeerSelector

    public PeerSelector getPeerSelector()

### getKBuckets

    KBucketSet getKBuckets()

### getDataStore

    DataStore getDataStore()

### getLastExploreNewDate

    long getLastExploreNewDate()

### setLastExploreNewDate

    void setLastExploreNewDate(long when)

### getExplicitSendKeys

    public java.util.Set getExplicitSendKeys()

### getPassivelySendKeys

    public java.util.Set getPassivelySendKeys()

### removeFromExplicitSend

    public void removeFromExplicitSend(java.util.Set toRemove)

### removeFromPassiveSend

    public void removeFromPassiveSend(java.util.Set toRemove)

### queueForPublishing

    public void queueForPublishing(java.util.Set toSend)

### getLastSent

    public java.lang.Long getLastSent(Hash key)

### noteKeySent

    public void noteKeySent(Hash key)

### getExploreKeys

    public java.util.Set getExploreKeys()

### removeFromExploreKeys

    public void removeFromExploreKeys(java.util.Set toRemove)

### queueForExploration

    public void queueForExploration(java.util.Set keys)

### shutdown

    public void shutdown()

  Description copied from interface: `Service`
  Instruct the service that the router is shutting down and that it should do whatever is necessary to go down gracefully. It should not depend on other components at this point. This call DOES block.

### restart

    public void restart()

  Description copied from interface: `Service`
  Perform a soft restart.

### getDbDir

    java.lang.String getDbDir()

### startup

    public void startup()

  Description copied from interface: `Service`
  Instruct the service that it should start normal operation. This call DOES block until the service is ready.

### createHandlers

    protected void createHandlers()

### findNearestRouters

    public java.util.Set findNearestRouters(Hash key,
                                            int maxNumRouters,
                                            java.util.Set peersToIgnore)

  Get the routers closest to that key in response to a remote lookup

  Specified by:
    `findNearestRouters` in class `NetworkDatabaseFacade`
  Parameters:
    `key` - The key
    `maxNumRouters` - The maximum number of routers to return
    `peersToIgnore` - Hash of routers not to include

### getAllRouters

    java.util.Set getAllRouters()

  get the hashes for all known routers

### getKnownRouters

    public int getKnownRouters()

  Overrides:
    `getKnownRouters` in class `NetworkDatabaseFacade`

### getKnownLeaseSets

    public int getKnownLeaseSets()

  Overrides:
    `getKnownLeaseSets` in class `NetworkDatabaseFacade`

### lookupLeaseSet

    public void lookupLeaseSet(Hash key,
                               Job onFindJob,
                               Job onFailedLookupJob,
                               long timeoutMs)

  Specified by:
    `lookupLeaseSet` in class `NetworkDatabaseFacade`

### lookupLeaseSetLocally

    public LeaseSet lookupLeaseSetLocally(Hash key)

  Specified by:
    `lookupLeaseSetLocally` in class `NetworkDatabaseFacade`

### lookupRouterInfo

    public void lookupRouterInfo(Hash key,
                                 Job onFindJob,
                                 Job onFailedLookupJob,
                                 long timeoutMs)

  Specified by:
    `lookupRouterInfo` in class `NetworkDatabaseFacade`

### lookupRouterInfoLocally

    public RouterInfo lookupRouterInfoLocally(Hash key)

  Specified by:
    `lookupRouterInfoLocally` in class `NetworkDatabaseFacade`

### publish

    public void publish(LeaseSet localLeaseSet)

  Specified by:
    `publish` in class `NetworkDatabaseFacade`

### stopPublishing

    void stopPublishing(Hash target)

### publish

    public void publish(RouterInfo localRouterInfo)
                 throws java.lang.IllegalArgumentException

  Specified by:
    `publish` in class `NetworkDatabaseFacade`
  Throws:
    `java.lang.IllegalArgumentException` - if the local router info is invalid

### validate

    java.lang.String validate(Hash key,
                              LeaseSet leaseSet)

  Determine whether this leaseSet will be accepted as valid and current given what we know now.

  Returns:
    reason why the entry is not valid, or null if it is valid

### store

    public LeaseSet store(Hash key,
                          LeaseSet leaseSet)
                   throws java.lang.IllegalArgumentException

  Store the leaseSet

  Specified by:
    `store` in class `NetworkDatabaseFacade`
  Throws:
    `java.lang.IllegalArgumentException` - if the leaseSet is not valid

### validate

    java.lang.String validate(Hash key,
                              RouterInfo routerInfo)
                        throws java.lang.IllegalArgumentException

  Determine whether this routerInfo will be accepted as valid and current given what we know now.

  Throws:
    `java.lang.IllegalArgumentException`

### store

    public RouterInfo store(Hash key,
                            RouterInfo routerInfo)
                     throws java.lang.IllegalArgumentException

  store the routerInfo

  Specified by:
    `store` in class `NetworkDatabaseFacade`
  Throws:
    `java.lang.IllegalArgumentException` - if the routerInfo is not valid

### fail

    public void fail(Hash dbEntry)

  Specified by:
    `fail` in class `NetworkDatabaseFacade`

### lookupBeforeDropping

    protected void lookupBeforeDropping(Hash peer,
                                        RouterInfo info)

### dropAfterLookupFailed

    protected void dropAfterLookupFailed(Hash peer,
                                         RouterInfo info)

### unpublish

    public void unpublish(LeaseSet localLeaseSet)

  Specified by:
    `unpublish` in class `NetworkDatabaseFacade`

### search

    SearchJob search(Hash key,
                     Job onFindJob,
                     Job onFailedLookupJob,
                     long timeoutMs,
                     boolean isLease)

  Begin a kademlia style search for the key specified, which can take up to timeoutMs and will fire the appropriate jobs on success or timeout (or if the kademlia search completes without any match)

### getPeerTimeout

    public int getPeerTimeout(Hash peer)

### sendStore

    public void sendStore(Hash key,
                          DataStructure ds,
                          Job onSuccess,
                          Job onFailure,
                          long sendTimeout,
                          java.util.Set toIgnore)

### renderStatusHTML

    public void renderStatusHTML(java.io.Writer out)
                          throws java.io.IOException

  Throws:
    `java.io.IOException`