Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 String` | `DEFAULT_DB_DIR`
`protected static long` | `DONT_FAIL_PERIOD` for the 10 minutes after startup, don't fail db entries so that if we were offline for a while, we'll have a chance of finding some live peers with the previous references
`(package private) static long` | `MAX_LEASE_FUTURE` Don't let leaseSets go 20 minutes into the future
`protected static int` | `MIN_REMAINING_ROUTERS` if we have less than this many routers left, don't drop any more, even if they're failing or doing bad shit.
`static String` | `PROP_DB_DIR`
`static String` | `PROP_ENFORCE_NETID`
`protected static long` | `PUBLISH_JOB_DELAY` this needs to be long enough to give us time to start up, but less than 20m (when we start accepting tunnels and could be a IBGW)

Constructor Summary
`KademliaNetworkDatabaseFacade(RouterContext context)`

Method Summary
`protected void` | `createHandlers()`
`protected PeerSelector` | `createPeerSelector()`
`protected void` | `dropAfterLookupFailed(Hash peer, RouterInfo info)`
`void` | `fail(Hash dbEntry)`
`Set<Hash>` | `findNearestRouters(Hash key, int maxNumRouters, Set<Hash> peersToIgnore)` Get the routers closest to that key in response to a remote lookup Only used by ../HDLMJ Set MAY INCLUDE our own router - add to peersToIgnore if you don't want
`Set<Hash>` | `getAllRouters()` get the hashes for all known routers
`(package private) DataStore` | `getDataStore()`
`(package private) String` | `getDbDir()`
`Set<Hash>` | `getExploreKeys()`
`(package private) KBucketSet` | `getKBuckets()`
`protected int` | `getKBucketSetSize()` This is fast and doesn't use synchronization, but it includes both routerinfos and leasesets.
`int` | `getKnownLeaseSets()` This is only used by StatisticsManager to publish the count if we are floodfill.
`int` | `getKnownRouters()`
`(package private) long` | `getLastExploreNewDate()`
`Set<LeaseSet>` | `getLeases()` public for NetDbRenderer in routerconsole
`PeerSelector` | `getPeerSelector()`
`int` | `getPeerTimeout(Hash peer)` todo: does this need more tuning?
`Set<RouterInfo>` | `getRouters()` public for NetDbRenderer in routerconsole
`boolean` | `isInitialized()`
`protected void` | `lookupBeforeDropping(Hash peer, RouterInfo info)` don't use directly - see F.N.D.F.
`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` | `publish(LeaseSet localLeaseSet)`
`void` | `publish(RouterInfo localRouterInfo)` Stores to local db only.
`void` | `queueForExploration(Set keys)`
`void` | `removeFromExploreKeys(Set toRemove)`
`void` | `rescan()`
`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) Unused - called only by FNDF.searchFull() from FloodSearchJob which is overridden - don't use this.
`(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, Set toIgnore)` unused (overridden in FNDF)
`(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
`RouterInfo` | `store(Hash key, RouterInfo routerInfo, boolean persist)`
`void` | `unpublish(LeaseSet localLeaseSet)`
`(package private) String` | `validate(Hash key, LeaseSet leaseSet)` Determine whether this leaseSet will be accepted as valid and current given what we know now.
`(package private) 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 net.i2p.router.NetworkDatabaseFacade
`renderStatusHTML`

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

### DONT_FAIL_PERIOD

    protected static final long DONT_FAIL_PERIOD

  for the 10 minutes after startup, don't fail db entries so that if we were offline for a while, we'll have a chance of finding some live peers with the previous references

  See Also:
    Constant Field Values

### PROP_ENFORCE_NETID

    public static final String PROP_ENFORCE_NETID

See Also:
  Constant Field Values

### PROP_DB_DIR

    public static final String PROP_DB_DIR

See Also:
  Constant Field Values

### DEFAULT_DB_DIR

    public static final String DEFAULT_DB_DIR

See Also:
  Constant Field Values

### MIN_REMAINING_ROUTERS

    protected static final int MIN_REMAINING_ROUTERS

  if we have less than this many routers left, don't drop any more, even if they're failing or doing bad shit.

  See Also:
    Constant Field Values

### PUBLISH_JOB_DELAY

    protected static final long PUBLISH_JOB_DELAY

  this needs to be long enough to give us time to start up, but less than 20m (when we start accepting tunnels and could be a IBGW)

  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

### isInitialized

    public boolean isInitialized()

  Overrides:
    `isInitialized` in class `NetworkDatabaseFacade`

### createPeerSelector

    protected PeerSelector createPeerSelector()

### getPeerSelector

    public PeerSelector getPeerSelector()

### getKBuckets

    KBucketSet getKBuckets()

### getDataStore

    DataStore getDataStore()

### getLastExploreNewDate

    long getLastExploreNewDate()

### setLastExploreNewDate

    void setLastExploreNewDate(long when)

### getExploreKeys

    public Set<Hash> getExploreKeys()

### removeFromExploreKeys

    public void removeFromExploreKeys(Set toRemove)

### queueForExploration

    public void queueForExploration(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.

### rescan

    public void rescan()

  Overrides:
    `rescan` in class `NetworkDatabaseFacade`

### getDbDir

    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 Set<Hash> findNearestRouters(Hash key,
                                        int maxNumRouters,
                                        Set<Hash> peersToIgnore)

  Get the routers closest to that key in response to a remote lookup Only used by ../HDLMJ Set MAY INCLUDE our own router - add to peersToIgnore if you don't want

  Specified by:
    `findNearestRouters` in class `NetworkDatabaseFacade`
  Parameters:
    `key` - the real key, NOT the routing key
    `peersToIgnore` - can be null
    `maxNumRouters` - The maximum number of routers to return

### getAllRouters

    public Set<Hash> getAllRouters()

  get the hashes for all known routers

  Specified by:
    `getAllRouters` in class `NetworkDatabaseFacade`

### getKnownRouters

    public int getKnownRouters()

  Overrides:
    `getKnownRouters` in class `NetworkDatabaseFacade`

### getKnownLeaseSets

    public int getKnownLeaseSets()

  This is only used by StatisticsManager to publish the count if we are floodfill. So to hide a clue that a popular eepsite is hosted on a floodfill router, only count leasesets that are "received as published", as of 0.7.14

  Overrides:
    `getKnownLeaseSets` in class `NetworkDatabaseFacade`

### getKBucketSetSize

    protected int getKBucketSetSize()

  This is fast and doesn't use synchronization, but it includes both routerinfos and leasesets. Use it to avoid deadlocks.

### 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 IllegalArgumentException

  Stores to local db only. Overridden in FNDF to actually send to the floodfills.

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

### validate

    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 IllegalArgumentException

  Store the leaseSet

  Specified by:
    `store` in class `NetworkDatabaseFacade`
  Returns:
    previous entry or null
  Throws:
    `IllegalArgumentException` - if the leaseSet is not valid

### validate

    String validate(Hash key,
                    RouterInfo routerInfo)
              throws IllegalArgumentException

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

  Throws:
    `IllegalArgumentException`

### store

    public RouterInfo store(Hash key,
                            RouterInfo routerInfo)
                     throws IllegalArgumentException

  store the routerInfo

  Specified by:
    `store` in class `NetworkDatabaseFacade`
  Returns:
    previous entry or null
  Throws:
    `IllegalArgumentException` - if the routerInfo is not valid

### store

    public RouterInfo store(Hash key,
                            RouterInfo routerInfo,
                            boolean persist)
                     throws IllegalArgumentException

  Throws:
    `IllegalArgumentException`

### fail

    public void fail(Hash dbEntry)

  Specified by:
    `fail` in class `NetworkDatabaseFacade`

### lookupBeforeDropping

    protected void lookupBeforeDropping(Hash peer,
                                        RouterInfo info)

  don't use directly - see F.N.D.F. override

### 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) Unused - called only by FNDF.searchFull() from FloodSearchJob which is overridden - don't use this.

### getLeases

    public Set<LeaseSet> getLeases()

  public for NetDbRenderer in routerconsole

  Overrides:
    `getLeases` in class `NetworkDatabaseFacade`

### getRouters

    public Set<RouterInfo> getRouters()

  public for NetDbRenderer in routerconsole

  Overrides:
    `getRouters` in class `NetworkDatabaseFacade`

### getPeerTimeout

    public int getPeerTimeout(Hash peer)

  todo: does this need more tuning?

### sendStore

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

  unused (overridden in FNDF)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD