|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.router.NetworkDatabaseFacade
net.i2p.router.networkdb.kademlia.KademliaNetworkDatabaseFacade
public class KademliaNetworkDatabaseFacade
Kademlia based version of the network database. Never instantiated directly; see FloodfillNetworkDatabaseFacade.
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 stuff. |
(package private) static int |
MIN_RESEED
Reseed if below this. |
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) Actually no, we need this soon if we are a new router or other routers have forgotten about us, else we can't build IB exploratory tunnels. |
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)
|
DatabaseEntry |
lookupLocally(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<Hash> keys)
|
void |
removeFromExploreKeys(Set<Hash> toRemove)
|
void |
rescan()
|
ReseedChecker |
reseedChecker()
|
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,
DatabaseEntry 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 |
(package private) 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 |
---|
protected final Log _log
protected final PeerSelector _peerSelector
protected final RouterContext _context
protected static final long DONT_FAIL_PERIOD
public static final String PROP_ENFORCE_NETID
public static final String PROP_DB_DIR
public static final String DEFAULT_DB_DIR
static final int MIN_RESEED
protected static final int MIN_REMAINING_ROUTERS
protected static final long PUBLISH_JOB_DELAY
static final long MAX_LEASE_FUTURE
Constructor Detail |
---|
public KademliaNetworkDatabaseFacade(RouterContext context)
Method Detail |
---|
void searchComplete(Hash key)
public boolean isInitialized()
isInitialized
in class NetworkDatabaseFacade
protected PeerSelector createPeerSelector()
public PeerSelector getPeerSelector()
public ReseedChecker reseedChecker()
reseedChecker
in class NetworkDatabaseFacade
KBucketSet getKBuckets()
DataStore getDataStore()
long getLastExploreNewDate()
void setLastExploreNewDate(long when)
public Set<Hash> getExploreKeys()
public void removeFromExploreKeys(Set<Hash> toRemove)
public void queueForExploration(Set<Hash> keys)
public void shutdown()
Service
public void restart()
Service
public void rescan()
rescan
in class NetworkDatabaseFacade
String getDbDir()
public void startup()
Service
protected void createHandlers()
public Set<Hash> findNearestRouters(Hash key, int maxNumRouters, Set<Hash> peersToIgnore)
findNearestRouters
in class NetworkDatabaseFacade
key
- the real key, NOT the routing keypeersToIgnore
- can be nullmaxNumRouters
- The maximum number of routers to returnpublic Set<Hash> getAllRouters()
getAllRouters
in class NetworkDatabaseFacade
public int getKnownRouters()
getKnownRouters
in class NetworkDatabaseFacade
public int getKnownLeaseSets()
getKnownLeaseSets
in class NetworkDatabaseFacade
protected int getKBucketSetSize()
public DatabaseEntry lookupLocally(Hash key)
lookupLocally
in class NetworkDatabaseFacade
public void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs)
lookupLeaseSet
in class NetworkDatabaseFacade
public LeaseSet lookupLeaseSetLocally(Hash key)
lookupLeaseSetLocally
in class NetworkDatabaseFacade
public void lookupRouterInfo(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs)
lookupRouterInfo
in class NetworkDatabaseFacade
public RouterInfo lookupRouterInfoLocally(Hash key)
lookupRouterInfoLocally
in class NetworkDatabaseFacade
public void publish(LeaseSet localLeaseSet)
publish
in class NetworkDatabaseFacade
void stopPublishing(Hash target)
public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException
publish
in class NetworkDatabaseFacade
IllegalArgumentException
- if the local router info is invalidString validate(Hash key, LeaseSet leaseSet)
public LeaseSet store(Hash key, LeaseSet leaseSet) throws IllegalArgumentException
store
in class NetworkDatabaseFacade
IllegalArgumentException
- if the leaseSet is not validString validate(Hash key, RouterInfo routerInfo) throws IllegalArgumentException
IllegalArgumentException
public RouterInfo store(Hash key, RouterInfo routerInfo) throws IllegalArgumentException
store
in class NetworkDatabaseFacade
IllegalArgumentException
- if the routerInfo is not validRouterInfo store(Hash key, RouterInfo routerInfo, boolean persist) throws IllegalArgumentException
IllegalArgumentException
public void fail(Hash dbEntry)
fail
in class NetworkDatabaseFacade
protected void lookupBeforeDropping(Hash peer, RouterInfo info)
protected void dropAfterLookupFailed(Hash peer, RouterInfo info)
public void unpublish(LeaseSet localLeaseSet)
unpublish
in class NetworkDatabaseFacade
SearchJob search(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease)
public Set<LeaseSet> getLeases()
getLeases
in class NetworkDatabaseFacade
public Set<RouterInfo> getRouters()
getRouters
in class NetworkDatabaseFacade
public int getPeerTimeout(Hash peer)
public void sendStore(Hash key, DatabaseEntry ds, Job onSuccess, Job onFailure, long sendTimeout, Set toIgnore)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |