public abstract class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade
| Modifier and Type | Field and Description |
|---|---|
protected RouterContext |
_context |
protected net.i2p.util.Log |
_log |
protected int |
_networkID |
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 int |
MAX_EXPLORE_QUEUE |
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 |
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 and Description |
|---|
KademliaNetworkDatabaseFacade(RouterContext context) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
createHandlers()
unused, see override
|
protected abstract PeerSelector |
createPeerSelector() |
(package private) void |
dropAfterLookupFailed(net.i2p.data.Hash peer)
Final remove for a router info.
|
void |
fail(net.i2p.data.Hash dbEntry)
Final remove for a leaseset.
|
(package private) void |
failPermanently(net.i2p.data.Destination dest)
Negative cache until restart
|
Set<net.i2p.data.Hash> |
findNearestRouters(net.i2p.data.Hash key,
int maxNumRouters,
Set<net.i2p.data.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<net.i2p.data.Hash> |
getAllRouters()
get the hashes for all known routers
|
List<net.i2p.data.BlindData> |
getBlindData()
For console ConfigKeyringHelper
|
net.i2p.data.BlindData |
getBlindData(net.i2p.data.SigningPublicKey spk) |
(package private) DataStore |
getDataStore() |
(package private) String |
getDbDir() |
Set<net.i2p.data.Hash> |
getExploreKeys() |
(package private) net.i2p.kademlia.KBucketSet<net.i2p.data.Hash> |
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()
This used to return the number of routers that were in
both the kbuckets AND the data store, which was fine when the kbuckets held everything.
|
(package private) long |
getLastExploreNewDate() |
long |
getLastRouterInfoPublishTime()
The last time we successfully published our RI.
|
Set<net.i2p.data.LeaseSet> |
getLeases()
public for NetDbRenderer in routerconsole
|
PeerSelector |
getPeerSelector() |
int |
getPeerTimeout(net.i2p.data.Hash peer)
todo: does this need more tuning?
|
Set<RouterInfo> |
getRouters()
public for NetDbRenderer in routerconsole
|
boolean |
isInitialized() |
(package private) boolean |
isNegativeCached(net.i2p.data.Hash key)
Is the key in the negative lookup cache?
|
boolean |
isNegativeCachedForever(net.i2p.data.Hash key)
Is it permanently negative cached?
|
protected void |
lookupBeforeDropping(net.i2p.data.Hash peer,
RouterInfo info)
don't use directly - see F.N.D.F.
|
void |
lookupDestination(net.i2p.data.Hash key,
Job onFinishedJob,
long timeoutMs,
net.i2p.data.Hash fromLocalDest)
Lookup using the client's tunnels
Succeeds even if LS validation and store fails due to unsupported sig type, expired, etc.
|
net.i2p.data.Destination |
lookupDestinationLocally(net.i2p.data.Hash key)
Lookup locally in netDB and in badDest cache
Succeeds even if LS validation fails due to unsupported sig type, expired, etc.
|
(package private) void |
lookupFailed(net.i2p.data.Hash key)
Increment in the negative lookup cache
|
void |
lookupLeaseSet(net.i2p.data.Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs)
Lookup using exploratory tunnels.
|
void |
lookupLeaseSet(net.i2p.data.Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs,
net.i2p.data.Hash fromLocalDest)
Lookup using the client's tunnels
Use lookupDestination() if you don't need the LS or don't need it validated.
|
net.i2p.data.LeaseSet |
lookupLeaseSetLocally(net.i2p.data.Hash key)
Use lookupDestination() if you don't need the LS or don't need it validated.
|
void |
lookupLeaseSetRemotely(net.i2p.data.Hash key,
net.i2p.data.Hash fromLocalDest)
Unconditionally lookup using the client's tunnels.
|
void |
lookupLeaseSetRemotely(net.i2p.data.Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs,
net.i2p.data.Hash fromLocalDest)
Unconditionally lookup using the client's tunnels.
|
net.i2p.data.DatabaseEntry |
lookupLocally(net.i2p.data.Hash key) |
net.i2p.data.DatabaseEntry |
lookupLocallyWithoutValidation(net.i2p.data.Hash key)
Not for use without validation
|
void |
lookupRouterInfo(net.i2p.data.Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs) |
RouterInfo |
lookupRouterInfoLocally(net.i2p.data.Hash key)
This will return immediately with the result or null.
|
void |
publish(net.i2p.data.LeaseSet localLeaseSet) |
void |
publish(RouterInfo localRouterInfo)
Stores to local db only.
|
void |
queueForExploration(Collection<net.i2p.data.Hash> keys) |
boolean |
removeBlindData(net.i2p.data.SigningPublicKey spk)
For console ConfigKeyringHelper
|
void |
removeFromExploreKeys(Collection<net.i2p.data.Hash> toRemove) |
void |
renderStatusHTML(Writer out)
Debug info, HTML formatted
|
void |
rescan() |
ReseedChecker |
reseedChecker() |
void |
restart()
Perform a soft restart.
|
(package private) void |
routerInfoPublishSuccessful()
Set the last time we successfully published our RI.
|
(package private) SearchJob |
search(net.i2p.data.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) SearchJob |
search(net.i2p.data.Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs,
boolean isLease,
net.i2p.data.Hash fromLocalDest)
Unused - see FNDF
|
(package private) void |
searchComplete(net.i2p.data.Hash key)
The search for the given key is no longer active
|
abstract void |
sendStore(net.i2p.data.Hash key,
net.i2p.data.DatabaseEntry ds,
Job onSuccess,
Job onFailure,
long sendTimeout,
Set<net.i2p.data.Hash> toIgnore)
unused (overridden in FNDF)
|
void |
setBlindData(net.i2p.data.BlindData bd) |
(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(net.i2p.data.Hash target) |
net.i2p.data.LeaseSet |
store(net.i2p.data.Hash key,
net.i2p.data.LeaseSet leaseSet)
Store the leaseSet.
|
RouterInfo |
store(net.i2p.data.Hash key,
RouterInfo routerInfo)
Store the routerInfo.
|
(package private) RouterInfo |
store(net.i2p.data.Hash key,
RouterInfo routerInfo,
boolean persist)
Store the routerInfo.
|
void |
unpublish(net.i2p.data.LeaseSet localLeaseSet) |
(package private) String |
validate(RouterInfo routerInfo)
Determine whether this routerInfo will be accepted as valid and current
given what we know now.
|
floodfillEnabled, storeprotected final net.i2p.util.Log _log
protected final PeerSelector _peerSelector
protected final RouterContext _context
protected final int _networkID
protected static final long DONT_FAIL_PERIOD
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 int MAX_EXPLORE_QUEUE
public KademliaNetworkDatabaseFacade(RouterContext context)
void searchComplete(net.i2p.data.Hash key)
public boolean isInitialized()
isInitialized in class NetworkDatabaseFacadeprotected abstract PeerSelector createPeerSelector()
public PeerSelector getPeerSelector()
public ReseedChecker reseedChecker()
reseedChecker in class NetworkDatabaseFacadenet.i2p.kademlia.KBucketSet<net.i2p.data.Hash> getKBuckets()
DataStore getDataStore()
long getLastExploreNewDate()
void setLastExploreNewDate(long when)
public Set<net.i2p.data.Hash> getExploreKeys()
public void removeFromExploreKeys(Collection<net.i2p.data.Hash> toRemove)
public void queueForExploration(Collection<net.i2p.data.Hash> keys)
public void shutdown()
Servicepublic void restart()
Servicepublic void rescan()
rescan in class NetworkDatabaseFacadeString getDbDir()
public void startup()
Serviceprotected void createHandlers()
public Set<net.i2p.data.Hash> findNearestRouters(net.i2p.data.Hash key, int maxNumRouters, Set<net.i2p.data.Hash> peersToIgnore)
findNearestRouters in class NetworkDatabaseFacadekey - the real key, NOT the routing keypeersToIgnore - can be nullmaxNumRouters - The maximum number of routers to returnpublic Set<net.i2p.data.Hash> getAllRouters()
getAllRouters in class NetworkDatabaseFacadepublic int getKnownRouters()
getKnownRouters in class NetworkDatabaseFacadepublic int getKnownLeaseSets()
getKnownLeaseSets in class NetworkDatabaseFacadeprotected int getKBucketSetSize()
public net.i2p.data.BlindData getBlindData(net.i2p.data.SigningPublicKey spk)
getBlindData in class NetworkDatabaseFacadespk - unblinded keypublic void setBlindData(net.i2p.data.BlindData bd)
setBlindData in class NetworkDatabaseFacadebd - new BlindData to put in the cachepublic List<net.i2p.data.BlindData> getBlindData()
getBlindData in class NetworkDatabaseFacadepublic boolean removeBlindData(net.i2p.data.SigningPublicKey spk)
removeBlindData in class NetworkDatabaseFacadespk - the unblinded public keypublic net.i2p.data.DatabaseEntry lookupLocally(net.i2p.data.Hash key)
lookupLocally in class NetworkDatabaseFacadepublic net.i2p.data.DatabaseEntry lookupLocallyWithoutValidation(net.i2p.data.Hash key)
lookupLocallyWithoutValidation in class NetworkDatabaseFacadepublic void lookupLeaseSet(net.i2p.data.Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs)
lookupLeaseSet in class NetworkDatabaseFacadepublic void lookupLeaseSet(net.i2p.data.Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs,
net.i2p.data.Hash fromLocalDest)
lookupLeaseSet in class NetworkDatabaseFacadefromLocalDest - use these tunnels for the lookup, or null for exploratorypublic void lookupLeaseSetRemotely(net.i2p.data.Hash key,
net.i2p.data.Hash fromLocalDest)
lookupLeaseSetRemotely in class NetworkDatabaseFacadefromLocalDest - use these tunnels for the lookup, or null for exploratorypublic void lookupLeaseSetRemotely(net.i2p.data.Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs,
net.i2p.data.Hash fromLocalDest)
lookupLeaseSetRemotely in class NetworkDatabaseFacadefromLocalDest - use these tunnels for the lookup, or null for exploratoryonFindJob - may be nullonFailedLookupJob - may be nullpublic net.i2p.data.LeaseSet lookupLeaseSetLocally(net.i2p.data.Hash key)
lookupLeaseSetLocally in class NetworkDatabaseFacadepublic void lookupDestination(net.i2p.data.Hash key,
Job onFinishedJob,
long timeoutMs,
net.i2p.data.Hash fromLocalDest)
lookupDestination in class NetworkDatabaseFacadeonFinishedJob - non-nullfromLocalDest - use these tunnels for the lookup, or null for exploratorypublic net.i2p.data.Destination lookupDestinationLocally(net.i2p.data.Hash key)
lookupDestinationLocally in class NetworkDatabaseFacadepublic void lookupRouterInfo(net.i2p.data.Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs)
lookupRouterInfo in class NetworkDatabaseFacadepublic RouterInfo lookupRouterInfoLocally(net.i2p.data.Hash key)
lookupRouterInfoLocally in class NetworkDatabaseFacadepublic void publish(net.i2p.data.LeaseSet localLeaseSet)
throws IllegalArgumentException
publish in class NetworkDatabaseFacadeIllegalArgumentException - if the leaseSet is not validvoid stopPublishing(net.i2p.data.Hash target)
public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException
publish in class NetworkDatabaseFacadeIllegalArgumentException - if the local router info is invalidvoid routerInfoPublishSuccessful()
public long getLastRouterInfoPublishTime()
getLastRouterInfoPublishTime in class NetworkDatabaseFacadepublic net.i2p.data.LeaseSet store(net.i2p.data.Hash key,
net.i2p.data.LeaseSet leaseSet)
throws IllegalArgumentException
store in class NetworkDatabaseFacadeIllegalArgumentException - if the leaseSet is not validUnsupportedCryptoException - if that's why it failed.String validate(RouterInfo routerInfo) throws IllegalArgumentException
IllegalArgumentExceptionpublic RouterInfo store(net.i2p.data.Hash key, RouterInfo routerInfo) throws IllegalArgumentException
store in class NetworkDatabaseFacadeIllegalArgumentException - if the routerInfo is not validUnsupportedCryptoException - if that's why it failed.RouterInfo store(net.i2p.data.Hash key, RouterInfo routerInfo, boolean persist) throws IllegalArgumentException
IllegalArgumentException - if the routerInfo is not validUnsupportedCryptoException - if that's why it failed.public void fail(net.i2p.data.Hash dbEntry)
fail in class NetworkDatabaseFacadeprotected void lookupBeforeDropping(net.i2p.data.Hash peer,
RouterInfo info)
void dropAfterLookupFailed(net.i2p.data.Hash peer)
public void unpublish(net.i2p.data.LeaseSet localLeaseSet)
unpublish in class NetworkDatabaseFacadeSearchJob search(net.i2p.data.Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease)
UnsupportedOperationException - alwaysSearchJob search(net.i2p.data.Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease, net.i2p.data.Hash fromLocalDest)
UnsupportedOperationException - alwayspublic Set<net.i2p.data.LeaseSet> getLeases()
getLeases in class NetworkDatabaseFacadepublic Set<RouterInfo> getRouters()
getRouters in class NetworkDatabaseFacadepublic int getPeerTimeout(net.i2p.data.Hash peer)
public abstract void sendStore(net.i2p.data.Hash key,
net.i2p.data.DatabaseEntry ds,
Job onSuccess,
Job onFailure,
long sendTimeout,
Set<net.i2p.data.Hash> toIgnore)
void lookupFailed(net.i2p.data.Hash key)
key - for Destinations or RouterIdentitiesboolean isNegativeCached(net.i2p.data.Hash key)
key - for Destinations or RouterIdentitiesvoid failPermanently(net.i2p.data.Destination dest)
public boolean isNegativeCachedForever(net.i2p.data.Hash key)
isNegativeCachedForever in class NetworkDatabaseFacadekey - only for Destinations; for RouterIdentities, see Banlistpublic void renderStatusHTML(Writer out) throws IOException
renderStatusHTML in interface ServicerenderStatusHTML in class NetworkDatabaseFacadeIOException