net.i2p.router.networkdb.kademlia
Class FloodfillNetworkDatabaseFacade

java.lang.Object
  extended by net.i2p.router.NetworkDatabaseFacade
      extended by net.i2p.router.networkdb.kademlia.KademliaNetworkDatabaseFacade
          extended by net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade
All Implemented Interfaces:
Service

public class FloodfillNetworkDatabaseFacade
extends KademliaNetworkDatabaseFacade


Field Summary
static char CAPACITY_FLOODFILL
           
protected static int MIN_ACTIVE_PEERS
          NTCP cons drop quickly but SSU takes a while, so it's prudent to keep this a little higher than 1 or 2.
(package private) static long PUBLISH_TIMEOUT
          This maybe could be shorter than RepublishLeaseSetJob.REPUBLISH_LEASESET_TIMEOUT, because we are sending direct, but unresponsive floodfills may take a while due to timeouts.
 
Fields inherited from class net.i2p.router.networkdb.kademlia.KademliaNetworkDatabaseFacade
_context, _log, _peerSelector, DEFAULT_DB_DIR, DONT_FAIL_PERIOD, MAX_LEASE_FUTURE, MIN_REMAINING_ROUTERS, PROP_DB_DIR, PROP_ENFORCE_NETID, PUBLISH_JOB_DELAY
 
Constructor Summary
FloodfillNetworkDatabaseFacade(RouterContext context)
           
 
Method Summary
(package private)  void complete(Hash key)
           
protected  void createHandlers()
           
protected  PeerSelector createPeerSelector()
           
 void flood(DataStructure ds)
          Send to a subset of all floodfill peers.
 boolean floodfillEnabled()
           
static boolean floodfillEnabled(RouterContext ctx)
           
 java.util.List<Hash> getFloodfillPeers()
          list of the Hashes of currently known floodfill peers; Returned list will not include our own hash.
 java.util.List<RouterInfo> getKnownRouterData()
           
static boolean isFloodfill(RouterInfo peer)
           
(package private)  boolean isVerifyInProgress(Hash h)
           
protected  void lookupBeforeDropping(Hash peer, RouterInfo info)
          Search for a newer router info, drop it from the db if the search fails, unless just started up or have bigger problems.
 void publish(RouterInfo localRouterInfo)
          Stores to local db only.
(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 searchFull(Hash key, java.util.List<Job> onFind, java.util.List<Job> onFailed, long timeoutMs, boolean isLease)
          Ok, the initial set of searches to the floodfill peers timed out, lets fall back on the wider kademlia-style searches Unused - called only by FloodSearchJob which is overridden - don't use this.
 void sendStore(Hash key, DataStructure ds, Job onSuccess, Job onFailure, long sendTimeout, java.util.Set toIgnore)
          unused (overridden in FNDF)
(package private)  void setFloodfillEnabled(boolean yes)
           
(package private)  boolean shouldThrottleFlood(Hash key)
          Increments and tests.
(package private)  boolean shouldThrottleLookup(Hash from, TunnelId id)
          Increments and tests.
 void startup()
          Instruct the service that it should start normal operation.
(package private)  void verifyFinished(Hash h)
           
(package private)  void verifyStarted(Hash h)
           
 
Methods inherited from class net.i2p.router.networkdb.kademlia.KademliaNetworkDatabaseFacade
dropAfterLookupFailed, fail, findNearestRouters, getAllRouters, getDataStore, getDbDir, getExploreKeys, getKBuckets, getKBucketSetSize, getKnownLeaseSets, getKnownRouters, getLastExploreNewDate, getLeases, getPeerSelector, getPeerTimeout, getRouters, isInitialized, lookupLeaseSet, lookupLeaseSetLocally, lookupRouterInfo, lookupRouterInfoLocally, publish, queueForExploration, removeFromExploreKeys, rescan, restart, searchComplete, setLastExploreNewDate, shutdown, stopPublishing, store, store, store, unpublish, validate, validate
 
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

CAPACITY_FLOODFILL

public static final char CAPACITY_FLOODFILL
See Also:
Constant Field Values

PUBLISH_TIMEOUT

static final long PUBLISH_TIMEOUT
This maybe could be shorter than RepublishLeaseSetJob.REPUBLISH_LEASESET_TIMEOUT, because we are sending direct, but unresponsive floodfills may take a while due to timeouts.

See Also:
Constant Field Values

MIN_ACTIVE_PEERS

protected static final int MIN_ACTIVE_PEERS
NTCP cons drop quickly but SSU takes a while, so it's prudent to keep this a little higher than 1 or 2.

See Also:
Constant Field Values
Constructor Detail

FloodfillNetworkDatabaseFacade

public FloodfillNetworkDatabaseFacade(RouterContext context)
Method Detail

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.

Specified by:
startup in interface Service
Overrides:
startup in class KademliaNetworkDatabaseFacade

createHandlers

protected void createHandlers()
Overrides:
createHandlers in class KademliaNetworkDatabaseFacade

publish

public void publish(RouterInfo localRouterInfo)
             throws java.lang.IllegalArgumentException
Description copied from class: KademliaNetworkDatabaseFacade
Stores to local db only. Overridden in FNDF to actually send to the floodfills.

Overrides:
publish in class KademliaNetworkDatabaseFacade
Throws:
java.lang.IllegalArgumentException - if the local router info is invalid

sendStore

public void sendStore(Hash key,
                      DataStructure ds,
                      Job onSuccess,
                      Job onFailure,
                      long sendTimeout,
                      java.util.Set toIgnore)
Description copied from class: KademliaNetworkDatabaseFacade
unused (overridden in FNDF)

Overrides:
sendStore in class KademliaNetworkDatabaseFacade

shouldThrottleFlood

boolean shouldThrottleFlood(Hash key)
Increments and tests.

Since:
0.7.11

shouldThrottleLookup

boolean shouldThrottleLookup(Hash from,
                             TunnelId id)
Increments and tests.

Since:
0.7.11

flood

public void flood(DataStructure ds)
Send to a subset of all floodfill peers. We do this to implement Kademlia within the floodfills, i.e. we flood to those closest to the key.


createPeerSelector

protected PeerSelector createPeerSelector()
Overrides:
createPeerSelector in class KademliaNetworkDatabaseFacade

setFloodfillEnabled

void setFloodfillEnabled(boolean yes)

floodfillEnabled

public boolean floodfillEnabled()

floodfillEnabled

public static boolean floodfillEnabled(RouterContext ctx)

isFloodfill

public static boolean isFloodfill(RouterInfo peer)

getKnownRouterData

public java.util.List<RouterInfo> getKnownRouterData()

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)

Overrides:
search in class KademliaNetworkDatabaseFacade

searchFull

void searchFull(Hash key,
                java.util.List<Job> onFind,
                java.util.List<Job> onFailed,
                long timeoutMs,
                boolean isLease)
Ok, the initial set of searches to the floodfill peers timed out, lets fall back on the wider kademlia-style searches Unused - called only by FloodSearchJob which is overridden - don't use this.


complete

void complete(Hash key)

getFloodfillPeers

public java.util.List<Hash> getFloodfillPeers()
list of the Hashes of currently known floodfill peers; Returned list will not include our own hash. List is not sorted and not shuffled.


isVerifyInProgress

boolean isVerifyInProgress(Hash h)
Since:
0.7.10

verifyStarted

void verifyStarted(Hash h)
Since:
0.7.10

verifyFinished

void verifyFinished(Hash h)
Since:
0.7.10

lookupBeforeDropping

protected void lookupBeforeDropping(Hash peer,
                                    RouterInfo info)
Search for a newer router info, drop it from the db if the search fails, unless just started up or have bigger problems.

Overrides:
lookupBeforeDropping in class KademliaNetworkDatabaseFacade