java.lang.Object
net.i2p.router.NetworkDatabaseFacade
net.i2p.router.dummy.DummyNetworkDatabaseFacade
- All Implemented Interfaces:
Service
In-memory network database implementation for testing and development scenarios. Provides basic router info storage and lookup functionality without persistence or network communication.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RouterContextThe router context the facade belongs to.private final Map<Hash, RouterInfo> Routers this dummy database knows.Constructor Summary
ConstructorsConstructorDescriptionCreate an empty in-memory database; nothing is read from disk.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidaccessLeaseSet(Hash key) Record access to a LeaseSet for refresh tracking.voidRecord a lookup failure.findNearestRouters(Hash key, int maxNumRouters, Set<Hash> peersToIgnore) Return the RouterInfo structures for the routers closest to the given key.All known router hashes.voidlookupDestination(Hash key, Job onFinishedJob, long timeoutMs, Hash fromLocalDest) Look up a destination using the client's tunnels.Look up a destination in the in-memory store.voidlookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) Look up a lease set in the network database.voidlookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) Lookup using the client's tunnels.Look up a LeaseSet in the local network database.voidlookupLeaseSetRemotely(Hash key, Hash fromLocalDest) Unconditionally lookup using the client's tunnels.voidlookupLeaseSetRemotely(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) Unconditionally lookup using the client's tunnels.lookupLocally(Hash key) Lookup a database entry locally.Not for use without validation.voidlookupRouterInfo(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) Look up a router info in the network database.Look up a router info in the in-memory store.voidPublish a key to the network.voidpublish(RouterInfo localRouterInfo) Publish a key to the network.voidRemove a lease set from tracking.voidrestart()Restart the network database, retaining the in-memory store.voidshutdown()Shut down and release resources.voidstartup()Start the network database and register the local router info.Store a key locally.store(Hash key, RouterInfo routerInfo) Store a key locally.voidRemove a key from publication.Methods inherited from class NetworkDatabaseFacade
floodfillEnabled, getBlindData, getBlindData, getClientLeases, getDebugStats, getFloodfillLeases, getKnownLeaseSets, getKnownRouters, getLastRouterInfoPublishTime, getLeases, getPublishedLeases, getRouters, getUnpublishedLeases, isInitialized, isNegativeCachedForever, purgeMatchingRouters, removeBlindData, renderStatusHTML, rescan, reseedChecker, routingKeyChanged, setBlindData, storeModifier and TypeMethodDescriptionbooleanFor convenience, so users don't have to cast to FNDF, and unit tests using Dummy NDF will work.The blind data for the given unblinded key, for console ConfigKeyringHelper.Look up the cached BlindData for the given key.The known client LeaseSets.long[]Debug overview stats: total keys, bucket count, per-bucket capacity and fullest bucket size, as {keys, buckets, capacity, fullest}.The known floodfill LeaseSets.intNumber of known LeaseSets.intNumber of known routers.longThe last time we successfully published our RI.All known LeaseSets for display.The known published LeaseSets.Public for NetDbRenderer in routerconsole.The known unpublished LeaseSets.booleanIs the network database initialized?booleanIs it permanently negative cached?voidTrigger a retroactive purge sweep of the NetDb.booleanFor console ConfigKeyringHelper.voidrenderStatusHTML(Writer out) Debug only - all user info moved to NetDbRenderer in router console.voidrescan()Rescan the network database.The reseed checker; the base facade has none, FNDF overrides this.voidNotify the netDB that the routing key changed at midnight UTC.voidCache the given BlindData for later lookup.store(Hash key, DatabaseEntry entry) Store a DatabaseEntry in the network database.
Field Details
_routers
Routers this dummy database knows._context
The router context the facade belongs to.
Constructor Details
DummyNetworkDatabaseFacade
Create an empty in-memory database; nothing is read from disk.- Parameters:
ctx- the router context, kept for callers that need the log or config
Method Details
restart
public void restart()Restart the network database, retaining the in-memory store.shutdown
public void shutdown()Shut down and release resources.startup
public void startup()Start the network database and register the local router info.lookupLocally
Description copied from class:NetworkDatabaseFacadeLookup a database entry locally.- Specified by:
lookupLocallyin classNetworkDatabaseFacade- Parameters:
key- the hash of the RouterInfo or LeaseSet to look up- Returns:
- RouterInfo, LeaseSet, or null
lookupLocallyWithoutValidation
Description copied from class:NetworkDatabaseFacadeNot for use without validation.- Specified by:
lookupLocallyWithoutValidationin classNetworkDatabaseFacade- Parameters:
key- the hash of the RouterInfo or LeaseSet to look up- Returns:
- RouterInfo, LeaseSet, or null, NOT validated
lookupLeaseSet
Look up a lease set in the network database.- Specified by:
lookupLeaseSetin classNetworkDatabaseFacade- Parameters:
key- the destination hash whose LeaseSet is soughtonFindJob- job to run on successonFailedLookupJob- job to run on failuretimeoutMs- timeout in milliseconds
lookupLeaseSet
public void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) Description copied from class:NetworkDatabaseFacadeLookup using the client's tunnels.- Specified by:
lookupLeaseSetin classNetworkDatabaseFacade- Parameters:
key- the destination hash whose LeaseSet is soughtonFindJob- job to run on successonFailedLookupJob- job to run on failuretimeoutMs- timeout in millisecondsfromLocalDest- use these tunnels for the lookup, or null for exploratory
lookupLeaseSetLocally
Description copied from class:NetworkDatabaseFacadeLook up a LeaseSet in the local network database.- Specified by:
lookupLeaseSetLocallyin classNetworkDatabaseFacade- Parameters:
key- the destination hash whose LeaseSet is sought- Returns:
- the LeaseSet, or null if not found
lookupLeaseSetRemotely
Description copied from class:NetworkDatabaseFacadeUnconditionally lookup using the client's tunnels. No success or failed jobs, no local lookup, no checks. Use this to refresh a leaseset before expiration.- Specified by:
lookupLeaseSetRemotelyin classNetworkDatabaseFacade- Parameters:
key- the destination hash whose LeaseSet is soughtfromLocalDest- use these tunnels for the lookup, or null for exploratory
lookupLeaseSetRemotely
public void lookupLeaseSetRemotely(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) Description copied from class:NetworkDatabaseFacadeUnconditionally lookup using the client's tunnels.- Specified by:
lookupLeaseSetRemotelyin classNetworkDatabaseFacade- Parameters:
key- the destination hash whose LeaseSet is soughtonFindJob- may be nullonFailedLookupJob- may be nulltimeoutMs- timeout in millisecondsfromLocalDest- use these tunnels for the lookup, or null for exploratory
lookupDestination
Look up a destination using the client's tunnels.- Specified by:
lookupDestinationin classNetworkDatabaseFacade- Parameters:
key- the destination hash whose LeaseSet is soughtonFinishedJob- job to run on successtimeoutMs- timeout in millisecondsfromLocalDest- use these tunnels for the lookup, or null for exploratory
lookupDestinationLocally
Look up a destination in the in-memory store.- Specified by:
lookupDestinationLocallyin classNetworkDatabaseFacade- Parameters:
key- the destination hash to look up- Returns:
- the Destination, or null if it is not known or is cached as bad
lookupRouterInfo
Look up a router info in the network database.- Specified by:
lookupRouterInfoin classNetworkDatabaseFacade- Parameters:
key- the router hash whose RouterInfo is soughtonFindJob- job to run on successonFailedLookupJob- job to run on failuretimeoutMs- timeout in milliseconds
lookupRouterInfoLocally
Look up a router info in the in-memory store.- Specified by:
lookupRouterInfoLocallyin classNetworkDatabaseFacade- Parameters:
key- the router hash whose RouterInfo is sought- Returns:
- the RouterInfo, or null if not found
publish
Publish a key to the network.- Specified by:
publishin classNetworkDatabaseFacade- Parameters:
localLeaseSet- the LeaseSet to publish
publish
Publish a key to the network.- Specified by:
publishin classNetworkDatabaseFacade- Parameters:
localRouterInfo- the RouterInfo to publish
store
Store a key locally.- Specified by:
storein classNetworkDatabaseFacade- Parameters:
key- the destination hash to file the LeaseSet underleaseSet- the LeaseSet to store- Returns:
- the leaseSet if another leaseSet already existed at that key
store
Store a key locally.- Specified by:
storein classNetworkDatabaseFacade- Parameters:
key- the router hash to file the RouterInfo underrouterInfo- the RouterInfo to store- Returns:
- the routerInfo if another router already existed at that key
unpublish
Remove a key from publication.- Specified by:
unpublishin classNetworkDatabaseFacade- Parameters:
localLeaseSet- the LeaseSet to unpublish
accessLeaseSet
Description copied from class:NetworkDatabaseFacadeRecord access to a LeaseSet for refresh tracking. Only tracks if we have tunnels built AND there's a hostname.- Specified by:
accessLeaseSetin classNetworkDatabaseFacade- Parameters:
key- the destination hash of the LeaseSet that was used
removeLeaseSetFromTracking
Remove a lease set from tracking.- Specified by:
removeLeaseSetFromTrackingin classNetworkDatabaseFacade- Parameters:
key- the destination hash of the LeaseSet to stop tracking
fail
Record a lookup failure.- Specified by:
failin classNetworkDatabaseFacade- Parameters:
dbEntry- the key of the entry to fail
getAllRouters
Description copied from class:NetworkDatabaseFacadeAll known router hashes.- Specified by:
getAllRoutersin classNetworkDatabaseFacade- Returns:
- set of router hashes
findNearestRouters
Description copied from class:NetworkDatabaseFacadeReturn the RouterInfo structures for the routers closest to the given key. At most maxNumRouters will be returned.- Specified by:
findNearestRoutersin classNetworkDatabaseFacade- Parameters:
key- the hash to measure Kademlia distance from, normally our own router hashmaxNumRouters- The maximum number of routers to returnpeersToIgnore- Hash of routers not to include- Returns:
- set of router hashes closest to the key