java.lang.Object
net.i2p.router.networkdb.kademlia.TransientDataStore
- All Implemented Interfaces:
DataStore
- Direct Known Subclasses:
PersistentDataStore
In-memory network database storage implementation.
Provides volatile storage for database entries with no persistence to disk. Optimized for fast access and low memory footprint with concurrent operations using ConcurrentHashMap for thread-safe access patterns.
Primarily used for client network databases and temporary storage during router operations where persistence is not required.
Note: This should not be used for the main router database where persistence is necessary. Use PersistentDataStore instead.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BanLoggerPeers that have sent bad data.protected final RouterContextRouter context this store was constructed with.private final ConcurrentHashMap<Hash, DatabaseEntry> Entries held only for this router's uptime.protected final LogLogger for this data store.Constructor Summary
ConstructorsConstructorDescriptionBuild an empty volatile store, pre-sizing the entry map and the ban logger.Method Summary
Modifier and TypeMethodDescriptionprivate booleancontainsCapability(RouterInfo ri, char capability) True if the router offers the capability.intNumber of lease sets in the store.booleanforcePut(Hash key, DatabaseEntry data) Unconditionally store, bypass all newer/older checks.The entry for the key, or null if not found.For PersistentDataStore only - don't use here.All stored entries.getKeys()Keys of all stored entries.All stored entries as key-value pairs.booleanWhether the data store is initialized.booleanWhether the data store contains the key.booleanput(Hash key, DatabaseEntry data) Store an entry, replacing any previous one for the key.booleanput(Hash key, DatabaseEntry data, boolean persist) For PersistentDataStore only - don't use here.Remove and return the entry for the key.For PersistentDataStore only - don't use here.voidrescan()No-op - the in-memory store has no external state to rescan.intsize()Entries currently stored.voidstop()Clear the in-memory store.toString()Debug string listing all stored entries.
Field Details
_log
Logger for this data store._data
Entries held only for this router's uptime._context
Router context this store was constructed with._banLogger
Peers that have sent bad data.
Constructor Details
TransientDataStore
Build an empty volatile store, pre-sizing the entry map and the ban logger.- Parameters:
ctx- router context supplying the log manager and initializing the ban logger
Method Details
isInitialized
public boolean isInitialized()Whether the data store is initialized.- Specified by:
isInitializedin interfaceDataStore- Returns:
- always true, an in-memory store has nothing to initialize
stop
rescan
size
getKeys
getEntries
All stored entries.- Specified by:
getEntriesin interfaceDataStore- Returns:
- Unmodifiable view, not a copy
getMapEntries
All stored entries as key-value pairs.- Specified by:
getMapEntriesin interfaceDataStore- Returns:
- Unmodifiable view, not a copy
get
For PersistentDataStore only - don't use here.- Specified by:
getin interfaceDataStore- Parameters:
key- the hash key to look uppersist- if true, keep the entry in persistent storage- Returns:
- the database entry, or null if not found
- Throws:
UnsupportedOperationException- always, this store has no persistence layer
get
The entry for the key, or null if not found.isKnown
countLeaseSets
public int countLeaseSets()Number of lease sets in the store.- Specified by:
countLeaseSetsin interfaceDataStore- Returns:
- the number of LeaseSets stored
put
For PersistentDataStore only - don't use here.- Specified by:
putin interfaceDataStore- Parameters:
key- the hash key to store underdata- the database entry to storepersist- if true, keep the entry in persistent storage- Returns:
- true if the store was successful
- Throws:
UnsupportedOperationException- always, this store has no persistence layer
put
Store an entry, replacing any previous one for the key.forcePut
Unconditionally store, bypass all newer/older checks.toString
remove
For PersistentDataStore only - don't use here.- Specified by:
removein interfaceDataStore- Parameters:
key- the hash key to removepersist- if true, also remove from persistent storage- Returns:
- the removed database entry, or null if not found
- Throws:
UnsupportedOperationException- always, this store has no persistence layer
remove
Remove and return the entry for the key.containsCapability
True if the router offers the capability.- Parameters:
ri- the router to checkcapability- the capability letter to look for- Returns:
- true if it offers it